java - In hibernate how to programmatically set the isolation level of a transaction, or how to create two transactions with different isolation levels -


I am using Hibernate 3.6 with MSSQL 2005, 2008, 2012.

I want to set the level of isolation of transactions created by the session, but I do not get any information about it.

This is my code

  Session = Factory. Pop session (); Transaction tx = null; Try {Tx = sess.beginTransaction (); // do some work ... tx.commit (); } Hold (runtime exception e) {if (tx! = Null) tx. Rollback (); Throw e // or display error message} {sess.close (); }  

I wish to do something like this

  sess.beginTransaction (1 | 2 | 4 | 8);  

Is this possible?

Thank you.

I just got a solution that worked for me

  (Force read comet) {this.Session.doWork (new work) {@Override throws public executed (connection connection) SQLException {connection.setTransactionIsolation (2);}}); }  

But you can see that it is for a complete connection and not for a specific transaction. There may still be a better solution.


Comments