-->
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.  [ 10 posts ] 
Author Message
 Post subject: HB-1293
PostPosted: Tue Jan 04, 2005 8:43 am 
Newbie

Joined: Tue Jan 04, 2005 8:17 am
Posts: 5
Hibernate version:2.1.7c

Mapping documents: Some classes setup with transactional cache

Code between sessionFactory.openSession() and session.close(): Managed by spring

Full stack trace of any exception that occurs: http://opensource.atlassian.com/project ... se/HB-1293

Name and version of the database you are using: Oracle 9i

The generated SQL (show_sql=true): Not relevant

Debug level Hibernate log excerpt: http://opensource.atlassian.com/project ... se/HB-1293



We see jbosscache 1.2 throwing the same exception when hibernate is configured using spring 1.1.3 via the usual spring idiom as explained in http://www.hibernate.org/110.html

Like this:

<bean id="myTransactionManager"
class="org.springframework.orm.hibernate.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="mySessionFactory"/>
</property>
</bean>

<bean id="myProductServiceTarget"
class="product.ProductServiceImpl">
<property name="productDao">
<ref bean="myProductDao"/>
</property>
</bean>

<bean id="myProductService"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="myTransactionManager"/>
</property>
<property name="target">
<ref bean="myProductServiceTarget"/>
</property>
<property name="transactionAttributes">
<props>
<prop
key="increasePrice*">PROPAGATION_REQUIRED</prop>
<prop
key="someOtherBusinessMethod">PROPAGATION_MANDATORY</prop>
</props>
</property>
</bean>

What I would like to learn is that in the reference doc of hibernate we have the following:

14.4.5. Strategy: transactional

The transactional cache strategy provides support for
fully transactional cache providers such as JBoss
TreeCache. Such a cache may only be used in a JTA
environment and you must specify
hibernate.transaction.manager_lookup_class.

But what I understand from posts in the fixed issue @ http://opensource.atlassian.com/project ... se/HB-1293

is that one should use HibernateTransactionManager instead of JTA
Is this contradicting with the reference doc?

In other words what I am asking is that how can we run spring/hibernate/jbosscache together?

Should one use JTA and configure jbosscache with a TxManager Lookup class or should it work fine simply by configuring the sessionfactory bean about the cacheprovider being jbosscache as in above?


Top
 Profile  
 
 Post subject: Re: HB-1293
PostPosted: Tue Jan 04, 2005 8:45 am 
Newbie

Joined: Tue Jan 04, 2005 8:17 am
Posts: 5
can.candan wrote:
Hibernate version:2.1.7c

Mapping documents: Some classes setup with transactional cache

Code between sessionFactory.openSession() and session.close(): Not relevant

Full stack trace of any exception that occurs: http://opensource.atlassian.com/project ... se/HB-1293

Name and version of the database you are using: Oracle 9i

The generated SQL (show_sql=true): Not relevant

Debug level Hibernate log excerpt: http://opensource.atlassian.com/project ... se/HB-1293



We see jbosscache 1.2 throwing the same exception when hibernate is configured using spring 1.1.3 via the usual spring idiom as explained in http://www.hibernate.org/110.html

Like this:

<bean id="myTransactionManager"
class="org.springframework.orm.hibernate.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="mySessionFactory"/>
</property>
</bean>

<bean id="myProductServiceTarget"
class="product.ProductServiceImpl">
<property name="productDao">
<ref bean="myProductDao"/>
</property>
</bean>

<bean id="myProductService"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="myTransactionManager"/>
</property>
<property name="target">
<ref bean="myProductServiceTarget"/>
</property>
<property name="transactionAttributes">
<props>
<prop
key="increasePrice*">PROPAGATION_REQUIRED</prop>
<prop
key="someOtherBusinessMethod">PROPAGATION_MANDATORY</prop>
</props>
</property>
</bean>

What I would like to learn is that in the reference doc of hibernate we have the following:

14.4.5. Strategy: transactional

The transactional cache strategy provides support for
fully transactional cache providers such as JBoss
TreeCache. Such a cache may only be used in a JTA
environment and you must specify
hibernate.transaction.manager_lookup_class.

But what I understand from posts in the fixed issue @ http://opensource.atlassian.com/project ... se/HB-1293

is that one should use HibernateTransactionManager instead of JTA
Is this contradicting with the reference doc?

In other words what I am asking is that how can we run spring/hibernate/jbosscache together?

Should one use JTA and configure jbosscache with a TxManager Lookup class or should it work fine simply by configuring the sessionfactory bean about the cacheprovider being jbosscache as in above?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 05, 2005 12:22 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
No idea what HibernateTransactionManager is, so can't really answer your question. The explanation in the jira case seems pretty self-evident to me. There is a problem when both Hibernate and JBossCache are used in conjunction with JTA transactions; both try to register synchronizations with the ongoing transaction and it seems that the JBossCache synch is given precedence during afterCompletion callbacks which is the cause of the problem.

The solution is to simply use the Hibernate transaction API in your code as this alleviates the issue altogether. How does one acheive that with Spring? No idea; you'd probably have to ask the Spring guys. Typically you'd do something like:
Code:
Session session = ...;
Transaction txn = session.beginTransaction(); // NOOP with ongoing JTA

// do my work

transaction.commit(); // Again, NOOP with ongoing JTA


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 05, 2005 12:30 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Fixed by allowing non-transactional put()/get() in JBoss Cache 1.1.1.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 08, 2005 8:42 am 
Newbie

Joined: Tue Jan 04, 2005 8:17 am
Posts: 5
Hi,

The HibernateTransactionManager of spring is of no significance here, when using it you end up with the same code as the one you mentioned being executed.

ie:

Session session = ...;
Transaction txn = session.beginTransaction(); // NOOP with ongoing JTA

// do my work

transaction.commit(); // Again, NOOP with ongoing JTA


The problem is that when we are not using JTA TxManager in a clustered environment, as told in the fix, we are still getting
net.sf.hibernate.cache.CacheException: org.jboss.cache.lock.TimeoutException:


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 08, 2005 8:45 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
I *seriously* doubt the spring classes are using the Hibernate Transaction API in the case of CMT. Please read entire responses, and not just the selective portion you wish to attune to.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 08, 2005 10:45 am 
Newbie

Joined: Tue Jan 04, 2005 8:17 am
Posts: 5
We dont use spring over the top of CMT. We dont have any ejbs..


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 08, 2005 11:41 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Please continue this discussion on the Spring forum then, it is clearly an obfuscated issue with Spring wrappers. If you'd like to continue in this thread, please only show Hibernate and or JBoss/JBossCache related code.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 08, 2005 1:32 pm 
Newbie

Joined: Tue Jan 04, 2005 8:17 am
Posts: 5
Ok thanks for the tip. If we talk about pure hibernate code. One should not use JTA and should not configure hibernate with a TxManager Lookup class. And one should use jobssCache v1.1.1 or above. Is that right?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 08, 2005 4:41 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
http://www.hibernate.org/245.html

(Yes, this will somehow end up in the reference documentation.)


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