Joined: Mon Aug 23, 2004 11:01 pm Posts: 1
|
What would be the best approach for implementing long running nested transaction support with hibernate? Long running transactions prevent the use of JDBC based nested transactions using rollback as connections are being re-used between different hibernate sessions due to pooling.
E.g.
1 create hibernate session
2 start txn A
2 objX.setName("Bob")
3 start txn B child of A
4 disconnect session
5 reconnect session
6 objX.setName("Steve")
7 abort txn B
8 disconnect session
9 reconnect session
10 commit txn A
Result objX.name == Bob
It seems as if using FlushMode.NEVER and cloning a session using serialization might provide the ability to do a logical 'rollback' to simulate the desired behavior. Something like...
1 create hibernate session A
2 objX (in scope of A).setName("Bob")
3 make hibernate session B clone of A
4 disconnect sessions
5 reconnect sessions
6 objX (in scope of A).setName("Steve")
7 close session A (without flushing)
8 retrieve objX in scope of session B
9 update references to objX in A to use objX in B (ouch!)
10 flush session A
Does this seem feasible? Is there a better way to achieve this, perhaps some mechanism to copy uncommitted state from the child to the parent??
Thanks
Louis
|
|