aspose file tools*
The moose likes Object Relational Mapping and the fly likes CMT does not rollback Tx in hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "CMT does not rollback Tx in hibernate" Watch "CMT does not rollback Tx in hibernate" New topic
Author

CMT does not rollback Tx in hibernate

jp
Greenhorn

Joined: Sep 29, 2008
Posts: 1
Please let me know whats wrong with my settings. CMT doesnot rollback hibernate Tx.

Details
--------
I'm using hibernate 3.0 , weblogic 9.2, EJB 2.x, Oracle9i. I'm trying to implement a transaction rollback mechanism in a project. But the transaction does not rollback. Here are my configurations:

hibernate.cfg.xml
---------------------
<property name="transaction.factory_class">org.hibernate.transaction.CMTTransactionFactory</property>
<property name="transaction.manager_lookup_class">org.hibernate.transaction.WeblogicTransactionManagerLookup</property>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="show_sql">false</property>
<property name="jdbc.batch_size">30</property>
<property name="hibernate.jdbc.batch_versioned_data">true</property>
<!-- new addition -->
<property name ="jndi.class">weblogic.jndi.WLInitialContextFactory</property>
<property name="current_session_context_class">thread</property>
.............

Flow
------
SLB1 is the business interface which has business methods with "Required" as transaction attribute.
Business delegate is also a SLB with Tx attribute as "Required".

Business delegate invokes the corresponding some other business interface's business method.

POJO does the CRUD operations with hibernate API's

frontend() -> BusinessDelegate().delegate() -> SLB1.execute() -> POJO.updateDB()

Pojo.update(Object obj)
-----------------
try {
// open session
// session.saveorUpdate(obj);
// session.flush();
} catch (HibernateException e) {
// log exception
throw e;
} finally {
closeSession();
}


SLB1.execute()
-------------------
try {
// call some local business method m1 - "select query"
// call PoJo.update(obj);
String a = null;
a.toString();

// call some local business method m2 - "select query"
} Catch(Exception e) {
// log exception
// throw exception to business delegate
}

Business delegate.delegate()
--------------------------------
try {
// call corresponding SLB1.execute() method
catch(Application exception) {
sessionctx.setRollbackOnly();
// throw exception to front end
}

I tried to test the rollback mechanism. Added a breakpoint using eclipse after the update method call in SLB1.execute method. After the update call, i have added a code which throws NullPointerException. Then when i checking the database, the object is modified.

Don't know what i'm missing. Can you please help me in fixing this issue ?

Thanks in advance
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3706
    
    5

"jp"

Welcome to the JavaRanch. We don't have many rules here but one in particular that we follow is it regards to permitted names. Please review The JavaRanch Naming Policy and updated your name accordingly.

Scott Selikoff, JavaRanch Bartender
[ September 30, 2008: Message edited by: Scott Selikoff ]

My Blog: Down Home Country Coding with Scott Selikoff
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: CMT does not rollback Tx in hibernate