}
public void testOverallLockMode() {
EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin();
QueryImpl jpaQuery = em.createQuery( "from Lockable l" ).unwrap( QueryImpl.class );
org.hibernate.impl.QueryImpl hqlQuery = (org.hibernate.impl.QueryImpl) jpaQuery.getHibernateQuery();
assertEquals( LockMode.NONE, hqlQuery.getLockOptions().getLockMode() );
assertNull( hqlQuery.getLockOptions().getAliasSpecificLockMode( "l" ) );
assertEquals( LockMode.NONE, hqlQuery.getLockOptions().getEffectiveLockMode( "l" ) );
// NOTE : LockModeType.READ should map to LockMode.OPTIMISTIC
jpaQuery.setLockMode( LockModeType.READ );
assertEquals( LockMode.OPTIMISTIC, hqlQuery.getLockOptions().getLockMode() );
assertNull( hqlQuery.getLockOptions().getAliasSpecificLockMode( "l" ) );
assertEquals( LockMode.OPTIMISTIC, hqlQuery.getLockOptions().getEffectiveLockMode( "l" ) );
jpaQuery.setHint( AvailableSettings.ALIAS_SPECIFIC_LOCK_MODE+".l", LockModeType.PESSIMISTIC_WRITE );
assertEquals( LockMode.OPTIMISTIC, hqlQuery.getLockOptions().getLockMode() );
assertEquals( LockMode.PESSIMISTIC_WRITE, hqlQuery.getLockOptions().getAliasSpecificLockMode( "l" ) );
assertEquals( LockMode.PESSIMISTIC_WRITE, hqlQuery.getLockOptions().getEffectiveLockMode( "l" ) );
em.getTransaction().commit();