These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: How to set hibernate.connection.release_mode?
PostPosted: Sun Jun 10, 2007 9:46 pm 
Newbie

Joined: Fri Jun 08, 2007 3:16 am
Posts: 11
I use hibernate-3.2.4.sp1,I guess after I use database connection,I should release it,I read from hibernate reference,it say it should set hibernate.connection.release_mode,I should write <property name="hibernate.connection.release_mode">after_transaction</property>,is it right? I should put this statement into which line of my hibernate.cfg.xml file? I am a newer of Hibernate,anyone could give me a detail example?

My hibernate.cfg.xml file is follows:
Code:
<?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="hibernate.connection.url">jdbc:oracle:thin:@127.0.0.1:1521:test</property>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.username">scott</property>
<property name="hibernate.connection.password">tiger</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<property name="hibernate.connection.release_mode">after_transaction</property><!--Right here?-->
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<!--<property name="hbm2ddl.auto">create</property>-->
<mapping resource="events/Event.hbm.xml"/>
</session-factory>
</hibernate-configuration>


My code is follows:
Code:
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
Event theEvent = new Event();
theEvent.setTitle(title);
theEvent.setDate(theDate);
session.save(theEvent);
session.getTransaction().commit();


Best Regards,
Edward


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 11, 2007 12:00 am 
Senior
Senior

Joined: Sat Aug 19, 2006 6:31 pm
Posts: 139
That would be the right place to put it. Although, not specifying it defaults to "auto" which is equivalent to "after_transaction".

However as noted here ( in table 3.4)

http://www.hibernate.org/hib_docs/v3/re ... n-optional

this configuration property only affects sessions obtained using the openSession() method. You were using getCurrentSession().

_________________
Don't forget to rate the reply if it helps..:)

Budyanto


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.