In this section, you will learn about hibernate configuration parameter hibernate.connection.release_mode.
Prior to Hibernate 3.x , JDBC connection management means that session gets the connection when first time it requires it and this session should maintain this connection until the session was closed.
After the introduction of Hibernate 3.x, the new feature introduced is connection release modes which tells a session how to deal with its JDBC connections.
The different release modes which is denoted by enumerated values of org.hibernate.ConnectionReleaseMode are given below :
Which release mode should be used can be set through configuration parameter hibernate.connection.release_mode. The possible value of this parameter and related connection mode is given below :
There are two ways of setting configuration parameter :
XML deployment descriptor : hibernate.cfg.xml
A sample configuration file hibernate.cfg.xml is given below :
<?xml version='1.0' encoding='utf-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <!-- Database connection settings --> <property name="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="connection.url">jdbc:mysql://192.168.10.13:3306/anky</property> <property name="connection.username">root</property> <property name="connection.password">root</property> <property name="connection.pool_size">1</property> <property name="dialect">org.hibernate.dialect.MySQLDialect</property> <property name="current_session_context_class">thread</property> <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property> <property name="show_sql">true</property> <property name="hbm2ddl.auto">validate</property> <property name="hibernate.connection.release_mode">auto</property> <mapping class="net.roseindia.WorkerDetail"/> <mapping class="net.roseindia.Worker"/> </session-factory> </hibernate-configuration>
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: hibernate.connection.release_mode
Post your Comment