Atomikos Forum

XA with Hibernate

Hello,

When I use your hibernate with spring integration sample, at some point , I get an infinite loop of some kind which ends with a stack overflow. Hibernate calls a getUserTransaction() mehod infinitely. This happens when i include:

<prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</prop>
              <prop key="hibernate.transaction.manager_lookup_class">com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup</prop>

I wont bother you with stack trace or my whole config because I fould a solution which works for now.

My questions are:

1. Why does Hibernate even need to know the user transaction? What does it do with it? I am not experienced but as far as i understand, as long as i tell hibernate just to do inserts updates and deletes, it should not bother with transactions or commits, unless i tell it so. So when i use XA ,it is my responsibility to commit, so hibernate doesnt need to know if i am XAing or not. XA is between me, my transaction manager, and the XADataSource. So why does hibernate ask for user transaction and lookup class and stuff? Apparently I am wrong here but i want to know where I am wrong. Hibernate guys know much better than me so where is the catch?

2. To overcome this problem with stackoverflow I decided to delete the two lines above from my spring configuration and dont tell hibernate anything about XA. I then saw that everything was ok, except that when i commited the transaction from atomikos userTransaction, the XA resource of my database returned TM_READONLY (or something like that) and nothing got written to db. I figured that this is because hibernate caches stuff or something, and doesnt send the stuff to db, so db reports to trans manager's prepare phase that no change is made. So what I did is call hibernate's session.flush() just before calling commit. It works. But I want to know if there is a problem that I dont see with this solution. Is this accepted or is it considered unsafe?

Thanks a lot,
Bill
Bill Radis Send private email
Monday, February 09, 2009
 
 
Hi,

AFAIK, Hibernate uses the transaction API callbacks to flush updates to the DBMS right before committing.

What version of Hibernate are you using? And what version of Atomikos?

Thanks
Guy Pardon Send private email
Monday, February 09, 2009
 
 
I am using Atomikos Transactions Essentials 3.4.4 with ActiveMQ 5.2.0 and Hibernate 3.3.1 GA. Database is Oracle 10g Enterprise.

(I use AtomikosDataSourceBean to configure the SessionFactory)

The pattern I implement is:
Receive form ActiveMq, process the message body, create an entity instance and call the hibernate session to save the entity. I dont use Message listener. I just: jms.receive(timeout) - process - hibernate.persist in a loop and commit after a manually set threshold of messages or a receive timeout, whichever hits first. This way threshold and timeout can be changed on the fly easily.
Bill Radis Send private email
Monday, February 09, 2009
 
 
There is a problem in your Hibernate config IMHO. You should stick to the proposed configuration as much as possible as to avoid this kind of issue.

Could you please post you Hibernate config and your Spring config (if you use it) as well as the stack trace you get ?
Ludovic Orban Send private email
Tuesday, February 10, 2009
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics