views:

112

answers:

1

Is there a way to run these queries as if I added a (NOLOCK) hint to them?

+1  A: 

If you really need this, then you want to do something like:

session.connection().setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);

which is identical to a nolock.

Before you do that, really think carefully if you want to do a dirty read. Most of the time people do this because it's what they've always done, rather than because it's the right thing to do. In particular, this does not work well with caching.

Actually, this thread goes into the issues a little. Read carefully before deciding.

GaryF
Thanks, Gary.Yes, I was looking for dirty reads. Our DBA's have recommended NOLOCK for all "selects" in this project area. Problems was, part of the SQLs were hibernate.
Feel