-->
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.  [ 1 post ] 
Author Message
 Post subject: Isolater.JtaDelegate bypasses TransactionFactory?
PostPosted: Tue Feb 10, 2009 2:16 pm 
Newbie

Joined: Wed Feb 04, 2009 1:44 pm
Posts: 7
In order to integrate JBossCache 3 into our app stack, I created a simple JTA impl that delegates work to underlying org.hibernate.JDBCTransaction. However, I am running into a problem with Isolater.JtaDelegate (to which org.hibernate.id.TableHiLoGenerator delegates work) because JtaDelegate does NOT use TransactionFactory in delegateWork() method.

When Session.beginTransaction() is called, Session delegates to JDBCContext which delegates creation of transaction to TransactionFactory:

Code:
   
public Transaction getTransaction() throws HibernateException {
      if (hibernateTransaction==null) {
         hibernateTransaction = owner.getFactory().getSettings()
               .getTransactionFactory()
               .createTransaction( this, owner );
      }
      return hibernateTransaction;
   }



In my case I created a new TransactionFactory impl that:
-creates a JDBCTransaction
-passes it to our JTA TransactionManager impl which wraps it into a javax.transaction.Transaction

However, Isolater.JtaDelegate.delegateWork does not use Hibernate Transaction API (bypassing TransactionFactory.createTransaction) but instead does this:

Code:
TransactionManager transactionManager = session.getFactory().getTransactionManager();
//later
transactionManager.begin();


Should this be used instead?

Code:
org.hibernate.Transaction tx = session.getFactory().getSettings().getTransactionFactory().createTransaction(session.getJDBCContext(), this);
tx.begin();


This way seems like Isolater wouldn't have to care whether JTA is being used or not...


I realize that strictly speaking a JTA implementation should create and start a transaction with TransactionManager.begin() call. However, I rely on TransactionFactory.createTransaction to run because I need method args of createTransaction(JDBCContext jdbcContext, Context transactionContext) to create a nested JDBCTransaction.


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

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.