-->
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.  [ 3 posts ] 
Author Message
 Post subject: Need help in understanding hibernate and JTA transactions
PostPosted: Tue Jun 17, 2008 8:54 am 
Newbie

Joined: Thu Feb 28, 2008 12:35 pm
Posts: 15
Hi all,

I have a question regarding the JTA transaction manager behavior with respect to hibernate.

I have an application with Spring and hibernate running on JBOSS. The Spring is configured to use JTA transaction manager of JBOSS. Also, we are using OSCACHE as the second level cache for hibernate.

The issue we are currently facing is in some environments (Testing, UAT), we observed that some of the OSCache'd hibernate objects are not reflecting updated values immediately.

In my local machine everything works perfectly. I had put the hibernate listener and OSCache statistics listener in my local and everything seems to be working perfectly fine. The transactions are getting injected properly and flush is invoked immediately after the method completion.

Only difference i observed with other environments is that the JBOSS is configured to run with higher memory setting for JVM.

Is it possible that hibernate/JTA is not flushing the objects immediately and we are seeing the earlier cached objects in these environments.

1. I want to know whether session.flush() happens immediately after each transaction
2. Can invoking session.flush() will immediately flush the objects to database.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 17, 2008 8:58 am 
Newbie

Joined: Thu Feb 28, 2008 12:35 pm
Posts: 15
Here is my hibernate properties in the mapping file:


<property name="hibernateProperties">
<props>
<prop key="connection.provider_class">org.hibernate.connection.DatasourceConnectionProvider</prop>
<prop key="jdbc.use_streams_for_binary">true</prop>
<prop key="jdbc.batch_size">0</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
<prop key="hibernate.query.substitutions">true 1, false 0</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.max_fetch_depth">2</prop>
<prop key="hibernate.cache.provider_class">com.opensymphony.oscache.hibernate.OSCacheProvider</prop>
<prop key="hibernate.cache.use_minimal_puts">true</prop>

<prop key="hibernate.cache.use_query_cache">false</prop>
<prop key="hibenrate.cache.use_structured_entries">true</prop>
<prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</prop>

<!-- for backward compatibility of hql queries -->
<prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
<prop key="jta.UserTransaction">UserTransaction</prop>
</props>
</property>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 17, 2008 3:29 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Flush will be called before the transaction is comitted:

Quote:
flush

public void flush()
throws HibernateException

Force this session to flush. Must be called at the end of a unit of work, before commiting the transaction and closing the session (depending on flush-mode, Transaction.commit() calls this method).

Flushing is the process of synchronizing the underlying persistent store with persistable state held in memory.


http://www.hibernate.org/hib_docs/v3/api/index.html

You might want to take a look at the JavaDoc for the Hibernate3 FlushMode

http://www.hibernate.org/hib_docs/v3/api/index.html

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.