-->
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.  [ 3 posts ] 
Author Message
 Post subject: Hibernate 3.0.5 w/WebSphere 6
PostPosted: Thu Sep 15, 2005 6:54 pm 
Newbie

Joined: Wed Mar 23, 2005 2:32 pm
Posts: 12
Hi All,
I am trying to use Hibernate 3 w/WAS 6. Below is my hibernate.cfg.xml file.

<hibernate-configuration>
<session-factory name="java:hibernate/SessionFactory">
<property name="connection.datasource">java:comp/env/jdbc/sos</property>
<property name="hibernate.transaction.factory_class">
org.hibernate.transaction.WebSphereExtendedJTATransactionLookup
</property>
<property name="hibernate.dialect">org.hibernate.dialect.DB2Dialect</property>

<mapping resource="com/acme/model/product.hbm.xml"/>
</session-factory>
</hibernate-configuration>

Resulting in a java.lang.ClassCastException: org.hibernate.transaction.WebSphereExtendedJTATransactionLookup.

Let me explain further. I am trying to use Hibernate with a stateless session bean with a test method call. The test method is defined as a transaction using the deployment descriptor. Therefore in my method I don't have a hibernate begin/commit transaction call. In the method I find and update an object using hibernate. Then I do a findall and discover my object has not been updated, all within this transaction. This is the opposite behaviour if I run standalone w/hibernate transactions. The updates are not flushed when the query is done. The database shows the record as not updated.

That's when I used the WebSphereExtendedJTATransactionLookup entry in the configuration file, resulting in the class cast exception.

I am hoping someone could help me out on what is the correct procedure to using hibernate in a SSB in WAS 6. Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 19, 2005 4:55 am 
Regular
Regular

Joined: Wed Feb 02, 2005 6:33 am
Posts: 70
We're using WAS 6, here's the transaction section of the hibernate configuration xml:

Code:
<property name="jta.UserTransaction">java:comp/UserTransaction</property>
<property name="TransactionStrategy">org.hibernate.transaction.JTATransactionFactory</property>
<property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
<property name="TransactionManagerLookup">org.hibernate.transaction.WebSphereTransactionManagerLookup</property>
<property name="transaction.manager_lookup_class">org.hibernate.transaction.WebSphereTransactionManagerLookup</property>
<property name="TransactionManagerLookupStrategy">org.hibernate.transaction.WebSphereTransactionManagerLookup</property>
<property name="transaction.auto_close_session">true</property>
<property name="transaction.flush_before_completion">true</property>


Also, if you start getting access problems on deployment, then put a was.policy file in your deployable unit with suitable access setting.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 19, 2005 3:36 pm 
Newbie

Joined: Wed Mar 23, 2005 2:32 pm
Posts: 12
CollinL it worked like a charm. Many thanks I could not have figured it out, without your help.

Just to reiterate, the business call in the session bean is similar to follows. I needed a session.flush to catch duplicate key exceptions and therefore be able to rollback the transaction.

Session session = null;
try {
// open a new Session

// Do an update or add
// using the session above.

// You can do a find records here which may do a flush.

// Flush the session
session.flush();

} catch (Throwable e) {
// rollback transaction by throwing exception
throw e;
} finally {
// close the session
}

And added the SSB to the deployment description Container Transactions marked "Required".
Thanks a million.


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