J2EE Application Server integration in Hibernate by R4R Team

Hibernate has the following integration points for J2EE infrastructure:

1. Container-managed datasources: Hibernate can use JDBC connections managed by the container and provided through JNDI. Usually, a JTA compatible TransactionManager and a ResourceManager take care of transaction management (CMT), especially distributed transaction handling across several datasources. We can also demarcate transaction boundaries programmatically (BMT), or you might want to use the optional Hibernate Transaction API for this to keep your code portable.

2. Automatic JNDI binding: Hibernate can bind its SessionFactory to JNDI after startup.

3. JTA Session binding: Hibernate Session can be automatically bound to the scope of JTA transactions. Simply lookup the SessionFactory from JNDI and get the current Session. Let Hibernate manage flushing and closing the Session when your JTA transaction completes. Transaction demarcation is either declarative (CMT) or programmatic (BMT/UserTransaction).

4. JMX deployment: JMX capable application server (JBoss AS), can choose to deploy Hibernate as a managed MBean. This saves the one line startup code to build SessionFactory from a Configuration. The container will startup HibernateService and also take care of service dependencies (datasource has to be available before Hibernate starts, etc).

Depending on environment, might have to set the configuration option hibernate.connection.aggressive_release to true if your application server shows "connection containment" exceptions.
Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!