| 1 | '''Option 1''' |
| 2 | Example of a Dao or Service object: |
| 3 | {{{ |
| 4 | @Repository |
| 5 | @Transactional |
| 6 | public class HibernateClinic implements Clinic { |
| 7 | @Autowired |
| 8 | private SessionFactory sessionFactory; |
| 9 | }}} |
| 10 | This configuaration needed: |
| 11 | {{{ |
| 12 | <bean id="erikExampleDao" class="org.geonetwork.dao.ebxml.ErikExampleDao"> |
| 13 | }}} |
| 14 | |
| 15 | '''Option 2''' |
| 16 | {{{ |
| 17 | public class ExampleDao extends HibernateDaoSupport { |
| 18 | void saveErikExampleDomain(ErikExampleDomain erikExampleDomain ) { |
| 19 | this.getHibernateTemplate().save(erikExampleDomain ); |
| 20 | } |
| 21 | |
| 22 | }}} |
| 23 | This configuaration needed: |
| 24 | {{{ |
| 25 | <bean id="erikExampleDao" class="org.geonetwork.dao.ebxml.ErikExampleDao"> |
| 26 | <property name="sessionFactory" ref="sessionFactory" /> |
| 27 | </bean> |
| 28 | |
| 29 | }}} |
| 30 | '''Chosen Option 2'''. 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. |