Transition from Hibernate 2 to Hibernate 4
Tried to go through the intermediate step from H2 to H3 but encountered some problems. So might as well go to H4.
- Use
org.springframework.orm.hibernate4.LocalSessionFactoryBean
instead oforg.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean.
It is similar in role to the same-named class in the orm.hibernate3 package. However, in practice, it is closer to AnnotationSessionFactoryBean since its core purpose is to bootstrap a SessionFactory from annotation scanning. It will do for both mapping files as well as annotated entities.
Hibernate configuration file -
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
2.
Services provide various types of functionality, in a pluggable manner. Specifically they are interfaces defining certain functionality and then implementations of those service contract interfaces. The interface is known as the service role; the implementation class is known as the service implementation. The pluggability comes from the fact that the service implementation adheres to contract defined by the interface of the service role and that consumers of the service program to the service role, not the implementation.
3. <bean id="hibernateCacheProvider" class="com.funtoro.app.hibernate.ExternalEhCacheProvider" depends-on="cacheManager"/>
The 'depends-on' attribute and property is used not only to specify an initialization time dependency, but also to specify the corresponding destroy time dependency (in the case of singleton beans only). Dependent beans that are defined in the 'depends-on' attribute will be destroyed first prior to the relevant bean itself being destroyed. This thus allows you to control shutdown order too.