-->
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: Integrate jboss narayana transaction manager with hibernate
PostPosted: Thu Sep 29, 2016 11:23 am 
Newbie

Joined: Tue Sep 27, 2016 10:26 am
Posts: 5
My standalone application already uses narayana transaction manager for JTA transaction with other XA resources and now I am trying to integrate it with Hiberante also. So that hibernate transactions also executes under narayana JTA transcation scope-

hibernate.cfg.xml

Code:
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="hibernate.transaction.factory_class">
  org.hibernate.transaction.JTATransactionFactory</property>

<property name="hibernate.transaction.manager_lookup_class">
   <!-- org.hibernate.transaction.JBossTransactionManagerLookup -->com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple
</property>

<property name="hibernate.current_session_context_class">jta</property>


other java conf -
Code:
registry.applySetting(AvailableSettings.JTA_PLATFORM,     "org.hibernate.service.jta.platform.internal.JBossStandAloneJtaPlatform");

registry.applySetting(AvailableSettings.TRANSACTION_COORDINATOR_STRATEGY,     "jta");


and here is how I am starting the transaction-

Code:
TransactionManager transactionManager     =com.arjuna.ats.jta.TransactionManager.transactionManager();
transactionManager.begin();

Session session = currentSessionContext.currentSession();

session.joinTransaction();
System.out.println("is joined "+session.isJoinedToTransaction());

session.update(obj);
transactionManager.commit();
session.close();
sessionFactory.close();


Now problem is that db is showing the changes of session only after call to sessionFactory.close() but shouldn't it be at transactionManager.commit() .

How can I configure it to make db update after transactionManager.commit() ?


Top
 Profile  
 
 Post subject: Re: Integrate jboss narayana transaction manager with hibernate
PostPosted: Fri Sep 30, 2016 7:42 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
I think you should be using a UserTransaction:

Code:
Context ctx = new InitialContext();

UserTransaction tx = (UserTransaction) ctx.lookup("java:comp/UserTransaction");
tx.begin();

Session session = currentSessionContext.currentSession();
session.update(obj);

tx.commit();


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.