dynamobi/enki — Issue #3: [ENK-7] Provide a mechanism to delay transaction start until an operation requires it
Author: dynamobi-build
Created: 2011-12-30 02:07:09+00:00
State: open
Labels: ENK

[reporter="stephan", created="Thu, 29 Jan 2009 14:11:52 -0500 (GMT-05:00)"]
Provide a mechanism to delay transaction start until an operation requires it.

This is useful, for instance, for Farrago where FarragoDbSession.commitImpl() begins a transaction, calls FarragoSessionIndexMap.onCommit() and then commits the transaction. FarragoSessionIndexMap often performs no work (because no temporary tables were in use). When running against MySQL the begin/end transaction pair causes packets to be needlessly sent to the server. In this case, one solution could be to check for work before beginning the transaction, but it is possible to detect this condition in Enki itself.

The necessary work is to modify HibernateMDRepository.beginTrans() to defer creation of the Hibernate transation. Then, all of the HibernateMDRepository and JMI methods that could require a transaction must be modified to detect the deferred transaction and create the transaction before doing any work. For example, getByMofId() should perform the test. So should HibernateRefClass.refAllOfClass/Type. There are certainly others. Finally, the endTrans() methods should detect a deferred and never-started transaction and handle it properly.