I have created a temporary solution. I'm using such method at the begining of a transaction:
Code:
public class LockTableUtil
private LockTableUtil(){}
public static void lockExclusive(Connection connection, String tableName)
throws SQLException{
PreparedStatement statement = connection
.prepareStatement("LOCK TABLE " + tableName +" IN EXCLUSIVE MODE");
try
{
statement.execute();
} finally
{
try
{
statement.close();
} catch (Exception e) {
// Swallow
}
}
}
This works. I'm planning move this code to interceptor.
I hope that it's temporary solution and the best one should be found.