Hibernate version: 2.1
Name and version of the database you are using: Oracle 9i
Hello,
My question is whether a connection taken directly off of a Session object which is explictly part of a transaction also falls under that same transaction.
I open the session and begin the transaction with:
Session lSession = HibernateUtil.getSession();
Transaction tx = HibernateUtil.beginTransaction(lSession);
Within the code and before the transaction, tx, is commited is the following code:
Connection lConn = pSession.connection();
lPStmt = lConn.prepareStatement(lUpdSql);
lConn.execute();
The problem is that there is a trigger that is immediately executed as a result of the lConn.execute(); line of code. I was under the impression that triggers did not fire until the transaction is committed. It is not until later that the transaction is committed with:
HibernateUtil.commitTransaction(tx);
If the connection is part of the transaction then the backup question is how can the connection read uncommitted inserts? The trigger is throwing an exception because it is trying to verify a foreign key constraint for a newly inserted key that has not been committed but is in the same transaction.
Thank you kindly for any insight.
|