-->
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: Can you use "Supports" in CMT with Hibernate?
PostPosted: Wed May 18, 2005 12:39 pm 
Newbie

Joined: Wed May 18, 2005 12:14 pm
Posts: 7
I have an existing application with stateless session beans using CMT. Methods that don't require a transaction -- typically ones that are only reading from the database -- are marked as "Supports". Others that do updates to multiple tables that must operate atomically are marked as "Required".

I am attempting to convert our current persistence mechanism to Hibernate. I'm using the CMTTransactionFactory in JBoss along with SessionFactory.getCurrentSession as described here:

http://blog.hibernate.org/cgi-bin/blosxom.cgi/2005/04/12

I'm having a problem with the "Supports" methods. If they are not part of a larger transaction, then Hibernate throws a NullPointerException in getCurrentSession (the code appears to expect a transaction to always be available). If I label them all as "Required", then everything works.

What is the preferred way to handle this scenario? Is there a way to use a CMT method marked as "Supports" with Hibernate? Or is it safe/efficient to simply mark all the methods as "Required", even though there are times when the methods don't really need a transaction?


Top
 Profile  
 
 Post subject: All 'Required' seems ok for me when not using Hibernate
PostPosted: Thu May 19, 2005 11:13 am 
Newbie

Joined: Thu May 19, 2005 10:14 am
Posts: 1
I am wondering about this same scenario. I have an existing app that uses Stateless Session EJBs with CMT. I am researching using Hibernate. Currently, methods that select and do not do update are marked with <trans-attribute>Supports</trans-attribute>. Methods that have several updates that must act as an atomic unit are marked with <trans-attribute>Required</trans-attribute>
I get the NullPointerException when I use Hibernate in the context of a 'Supports' method.
I've done some limited load testing of the app in its current condition 'not using Hibernate'. I get equivalent results in terms of response times when I change all the read-only 'Supports' methods to 'Required'. This makes me feel somewhat ok with changing all trans-attributes to 'Required'.
The application is a very large one that must support heavy user load and perform well. A lot of the EJB methods call each other. I'm a little concerned that if I move to Hibernate and cause all methods that interact with the DB to use container transaction management, I will increase duration of transactions and potentially cause unnecessary wait time and contention.
It would be interesting to know if anyone else has insight into consequences of causing all methods to require a transaction for the duration of the method when using CMT/Hibernate.


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.