-->
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: Synchronize Hibernate Cache with JTA
PostPosted: Fri Nov 14, 2003 6:22 am 
Newbie

Joined: Thu Sep 04, 2003 3:36 am
Posts: 11
Location: Karlsruhe/Germany
Hallo,

first of all, we are using
Hibernate 2.0.3
JBoss 3.0.4
MySQL 4.1a

What we are trying to do, is using Hibernate with JTA. The config-file looks something like
Code:
...
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<property name="connection.datasource">java:/MyOwnDS</property>
<property name="session_factory_name">java:/hibernate/HibernateFactory</property>
<property name="transaction.factory_class">net.sf.hibernate.transaction.JTATransactionFactory</property>
<property name="transaction.manager_lookup_class">net.sf.hibernate.transaction.JBossTransactionManagerLookup</property>
<property name="jta.UserTransaction">UserTransaction</property>

<mapping file="...


As I understood, we can use the Hibernate-Transaction-API together with BMT- and CMT-EJBs:
Code:
//--- SFSB method
UserTransaction ut = (UserTransaction)initialContext().lookup("UserTransaction");
ut.begin();

...

session.reconnect();
Transaction tx = session.beginTransaction();
ValueObject vo1 = session.load(ValueObject.class, id);
vo1.someAttribute = 123;
tx.commit();
session.disconnect();

...

ut.rollback();

Rollback was successful, no DB changes were made.

Later we load the same Object again
Code:
session.reconnect();
Transaction tx = session.beginTransaction();
ValueObject vo2 = session.load(ValueObject.class, id);
tx.commit();
session.disconnect();

but Hibernate serves the request from its Session cache(?) and vo2.someAttribute is still == 123. So it looks like the cache is not aware of the JTA transaction.
It would be great if someone could give me a hint, what we are missing here.

TIA
Philipp


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 14, 2003 7:40 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Hibernate does not roll back the session cache when the transaction rolls back. There would be a big performance cost to supporting this. It is intended that you discard the session when you roll back a transaction.

However, I am considering supporting savepoints/rollback to savepoints in Hibernate 2.2 timeline. Still needs some thought, however. We must let the user be able to turn this off, so as not to suffer the performance penalty.


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.