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.  [ 1 post ] 
Author Message
 Post subject: How to force hibernate to start transaction?
PostPosted: Mon Sep 28, 2009 5:29 am 
Newbie

Joined: Tue Sep 22, 2009 8:53 am
Posts: 1
Hi!

I have Hibernate3-3.2.5 and Oracle10g. I have problem with that code:

Code:
Connection connection = session.connection();   
connection.setAutoCommit(false);           
tx = session.beginTransaction();
tx.begin();
String statement = "{call SWIA.CALC_INIT(?,?,?,?,?,?,?,?,?,?,?)}";
CallableStatement cs =  connection.prepareCall(statement);
//...(set parameters)
cs.execute

String statement2 = "{call SWIA.CALC_C(?,?,?)}";
CallableStatement cs2 =  connection.prepareCall(statement);
//...(set parameters)
cs2.execute
//...(get results)

//... I execute many many procedures with that way....
tx.rollback(); // last instruction

The problem is that hibernate never start transaction in DB. I check
that because all of above procedures have that(below) code in their body (SQL), for
example - proc SWIA.CALC_INIT:
Code:
web_user.mylog.PR_LOG('SESSION id=' || NVL(DBMS_sessiON.UNIQUE_SESSION_ID,'NULL') || ' TRANSACTION id =' ||   NVL(DBMS_transaction.LOCAL_TRANSACTION_ID(FALSE),'NULL') ||  ' SRC = SWIA.CALC_INIT', 'BUG27619');


Procedure PR_LOG writes log to table LOG with autonomic transaction -
so it always work(I tested it by running procedures on DB). But always
after I run java code above in table LOG is:

SESSION id=XXXXXXXX TRANSACTION id=NULL SRC=SWIA.CALC_INIT

It means that hibernate doesn't start transaction before his running
procedures.

It's very important to me to call that procedures in one transaction
(because CALC_INIT make context in DB - and many threads must make
isolation calculations). In my application i use many sessions and
connections. What should I do to force Hibernate to start transaction
in current session?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.