jp

Greenhorn
+ Follow
since Sep 29, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by jp

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