use of org.hibernate.LockOptions in project hibernate-orm by hibernate.
the class OracleFollowOnLockingTest method testPessimisticLockWithMaxResultsAndOrderByWhileExplicitlyDisablingFollowOnLockingThenFails.
@Test
public void testPessimisticLockWithMaxResultsAndOrderByWhileExplicitlyDisablingFollowOnLockingThenFails() {
final Session session = openSession();
session.beginTransaction();
sqlStatementInterceptor.getSqlQueries().clear();
try {
List<Product> products = session.createQuery("select p from Product p order by p.id", Product.class).setLockOptions(new LockOptions(LockMode.PESSIMISTIC_WRITE).setFollowOnLocking(false)).setMaxResults(10).getResultList();
fail("Should throw exception since Oracle does not support ORDER BY if follow on locking is disabled");
} catch (PersistenceException expected) {
assertEquals(SQLGrammarException.class, expected.getCause().getClass());
}
}
use of org.hibernate.LockOptions in project hibernate-orm by hibernate.
the class SQLServer2005LockHintsTest method lockOptions.
@Override
protected LockOptions lockOptions(String aliasToLock) {
LockOptions lockOptions = new LockOptions(LockMode.PESSIMISTIC_WRITE).setTimeOut(LockOptions.NO_WAIT);
lockOptions.setAliasSpecificLockMode(aliasToLock, LockMode.PESSIMISTIC_WRITE);
return lockOptions;
}
use of org.hibernate.LockOptions in project hibernate-orm by hibernate.
the class HANALockTimeoutTest method testLockTimeoutNoAliasNoWait.
@Test
public void testLockTimeoutNoAliasNoWait() {
assertEquals(" for update nowait", dialect.getForUpdateString(new LockOptions(LockMode.PESSIMISTIC_READ).setTimeOut(LockOptions.NO_WAIT)));
assertEquals(" for update nowait", dialect.getForUpdateString(new LockOptions(LockMode.PESSIMISTIC_WRITE).setTimeOut(LockOptions.NO_WAIT)));
}
use of org.hibernate.LockOptions in project hibernate-orm by hibernate.
the class OracleLockTimeoutTest method testLockTimeoutAliasNoTimeout.
@Test
public void testLockTimeoutAliasNoTimeout() {
String alias = "a";
assertEquals(" for update", dialect.getForUpdateString(alias, new LockOptions(LockMode.PESSIMISTIC_READ).setAliasSpecificLockMode(alias, LockMode.PESSIMISTIC_READ)));
assertEquals(" for update", dialect.getForUpdateString(alias, new LockOptions(LockMode.PESSIMISTIC_WRITE).setAliasSpecificLockMode(alias, LockMode.PESSIMISTIC_WRITE)));
}
use of org.hibernate.LockOptions in project hibernate-orm by hibernate.
the class OracleLockTimeoutTest method testLockTimeoutNoAliasSkipLocked.
@Test
public void testLockTimeoutNoAliasSkipLocked() {
assertEquals(" for update skip locked", dialect.getForUpdateString(new LockOptions(LockMode.PESSIMISTIC_READ).setTimeOut(LockOptions.SKIP_LOCKED)));
assertEquals(" for update skip locked", dialect.getForUpdateString(new LockOptions(LockMode.PESSIMISTIC_WRITE).setTimeOut(LockOptions.SKIP_LOCKED)));
}
Aggregations