Changes between Version 4 and Version 5 of Spring


Ignore:
Timestamp:
11/12/08 00:18:11 (16 years ago)
Author:
erikvaningen
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Spring

    v4 v5  
    3131        </bean>
    3232}}}
    33 '''Chosen Option 1'''. This option is chosen because (1) one line less of configuration (2) It is working directly with the sessionFactory instead of a Facade like HibernateTemplate. Working with a template can have advantages. However in case of Hibernate, Spring has little to add because Hibernate is a very mature package. (3) SessionFactory is directly available. This might be necessary in cases of more advanced use of Hibernate.
     33'''Option 3'''
     34{{{
     35public class ExampleDao extends HibernateDaoSupport {
     36        void saveErikExampleDomain(ErikExampleDomain erikExampleDomain ) {
     37                this.getHibernateTemplate().save(erikExampleDomain );
     38        }
     39
     40}}}
     41This configuaration needed:
     42{{{
     43        <bean id="hibernateDaoSupport" class="org.springframework.orm.hibernate3.support.HibernateDaoSupport" abstract="true">
     44                <property name="sessionFactory">
     45                        <ref bean="sessionFactory" />
     46                </property>
     47        </bean>
     48        <bean id="erikExampleDao" class="org.geonetwork.dao.ebxml.ErikExampleDao" parent="hibernateDaoSupport" />
     49}}}
     50
     51'''Chosen Option 3'''. First Option 1 was chosen because of : This option is chosen because (1) one line less of configuration (2) It is working directly with the sessionFactory instead of a Facade like HibernateTemplate. Working with a template can have advantages. However in case of Hibernate, Spring has little to add because Hibernate is a very mature package. (3) SessionFactory is directly available. This might be necessary in cases of more advanced use of Hibernate.
     52
     53Option 3 has been chosen after a tip from Jose. Option 3 has a little bit more configuration at the beginning. But for each Dao there is only one line of configuration needed. This is more elegant especially when there will be more Dao's. The sessionFactory is still available via this.getSessionFactory().
     54
     55
    3456
    3557In option 1 you see as well the annotations @Transactional and @Repository. @Transaction means that every method in this Dao is considered as a transaction. @Repository has to do with the way Spring handles exceptions.