-->
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.  [ 4 posts ] 
Author Message
 Post subject: JTA and CMT Transactions
PostPosted: Thu Mar 22, 2007 10:42 am 
Newbie

Joined: Thu Mar 15, 2007 2:53 pm
Posts: 9
I am using hibernate 3.2 in weblogic 9.2 environment.

I want to use session bean demarcation for transactions. I know I can do this by specifying CMT TransactionFactory.

I also want to call the select operations from controller without going through ejb session bean. Something like.

UserDao.findById(xx); or User.getAddress();

When I run this code hiberante is throwing an exception saying there is no JTA transaction present.

Any suggestions appreciated. Or If this is a bad idea to do like this I would appreciate your comments.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 22, 2007 11:34 am 
Beginner
Beginner

Joined: Wed Mar 14, 2007 10:19 am
Posts: 24
Is there any case that in your hibernate.cfg.xml you have set a value
related to JTA for the properties:
transaction.manager_lookup_class or hibernate.transaction.factory_class?

Do you want to use JTA?

I haven't use weblogic, but I have used Hibernate with Tomcat, so I have used JTA for this case and in my hibernate.cfg.xml I have set:

<property name="hibernate.transaction.manager_lookup_class"> org.hibernate.transaction.JOTMTransactionManagerLookup</property>

Here you should use a transactionManagerLookUp that is supported by weblogic.

<property name="hibernate.transaction.factory_class">
org.hibernate.transaction.JTATransactionFactory</property>


Let me know if this helped.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 22, 2007 11:39 am 
Newbie

Joined: Thu Mar 15, 2007 2:53 pm
Posts: 9
I am using the following properties and I don't have any problem with JTA or CMT. Only trouble is when I can call from controller, I was hoping hiberate would start a transaction when there is no transaction. But it is not doing that.



<property name="transaction.factory_class">org.hibernate.transaction.CMTTransactionFactory</property>
<property name="transaction.manager_lookup_class">org.hibernate.transaction.WeblogicTransactionManagerLookup</property>
<property name="query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 22, 2007 11:56 am 
Beginner
Beginner

Joined: Wed Mar 14, 2007 10:19 am
Posts: 24
I don't thing that Hibernate would know when to start a transaction unless you say it so.Even if transactions are automatically handled by weblogic, a new transaction would automatically start in you session bean not in the controller . If you want a new transaction to start in the controller you can use Hibernate transaction
org.hibernate.Transaction tx = session.begin();
session = HibernateUtils.getCurrentSession();
.....
session.close();
tx.close();


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