Skip to content

Commit

Permalink
HHH-5275 - Criteria.setLockMode does not work correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
sebersole committed Jan 4, 2012
1 parent ab94a18 commit 76ac264
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ public void cleanupData() {
session.close();
}

@Test( timeout = 6000 )
// @Test( timeout = 6000 )
@Test
@SuppressWarnings( {"deprecation"})
public void testLoading() {
// open a session, begin a transaction and lock row
Expand All @@ -92,7 +93,7 @@ public void testLoading() {
}
}

@Test( timeout = 6000 )
@Test
@FailureExpected( jiraKey = "HHH-5275" )
public void testLegacyCriteria() {
// open a session, begin a transaction and lock row
Expand All @@ -115,7 +116,7 @@ public void testLegacyCriteria() {
}
}

@Test( timeout = 6000 )
@Test
@FailureExpected( jiraKey = "HHH-5275" )
public void testLegacyCriteriaAliasSpecific() {
// open a session, begin a transaction and lock row
Expand All @@ -138,7 +139,7 @@ public void testLegacyCriteriaAliasSpecific() {
}
}

@Test( timeout = 6000 )
@Test
@FailureExpected( jiraKey = "HHH-5275" )
public void testQuery() {
// open a session, begin a transaction and lock row
Expand All @@ -161,7 +162,7 @@ public void testQuery() {
}
}

@Test( timeout = 6000 )
@Test
public void testQueryUsingLockOptions() {
// todo : need an association here to make sure the alias-specific lock modes are applied correctly
Session s1 = sessionFactory().openSession();
Expand All @@ -180,8 +181,14 @@ private void nowAttemptToUpdateRow() {
Session s = sessionFactory().openSession();
s.beginTransaction();
try {
A it2 = (A) s.get( A.class, 1 );
it2.setValue( "changed" );
// load with write lock to deal with databases that block (wait indefinitely) direct attempts
// to write a locked row
A it = (A) s.get(
A.class,
1,
new LockOptions( LockMode.PESSIMISTIC_WRITE ).setTimeOut( LockOptions.NO_WAIT )
);
it.setValue( "changed" );
s.flush();
fail( "Pessimistic lock not obtained/held" );
}
Expand Down

0 comments on commit 76ac264

Please sign in to comment.