[hibernate-dev] lock timeout support
Steve Ebersole
steve at hibernate.org
Mon Jun 4 15:33:20 EDT 2012
On Fri 01 Jun 2012 07:21:32 AM CDT, Strong Liu wrote:
> when using connection pool or datasource, there is not a way to set
> the connection level settings for each query, is it?
Sure you can. Psuedo-code:
dialect.setLockTimeout( theConnection );
try {
executeTheStatement();
}
finally {
try {
dialect.resetLockTimeout( theConnection );
}
catch( ... ) {
...
}
}
Like I mentioned, the one thing that concerns me is tracking what the
connection-specific lock timeout might have been originally to properly
reset it in resetLockTimeout. One option is to externalize it:
final int originalTimeoutValue = dialect.setLockTimeout( theConnection
);
try {
executeTheStatement();
}
finally {
try {
dialect.resetLockTimeout( theConnection, originalTimeoutValue );
}
catch( ... ) {
...
}
}
> it is a hint as defined in JPA spec, so if we choose this way, I would
> suggest (b)
Just because JPA defines something a particular way does not make it
right. It uses the term "hint" in relation to queries for anything
that is specifically targeting a feature of the underlying vendor as
well, and those are not necessarily hints.
--
steve at hibernate.org
http://hibernate.org
More information about the hibernate-dev
mailing list