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_INITIt 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?