HHH-5275 - Criteria.setLockMode does not work correctly
This commit is contained in:
parent
cc15ba3f58
commit
e69104cd23
|
@ -1,11 +1,10 @@
|
|||
// $Id:$
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
|
||||
* third-party contributors as indicated by either @author tags or express
|
||||
* copyright attribution statements applied by the authors. All
|
||||
* third-party contributions are distributed under license by Red Hat Inc.
|
||||
* Copyright (c) 2009-2012, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
|
@ -23,13 +22,13 @@
|
|||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* Contains locking details (LockMode, Timeout and Scope).
|
||||
*
|
||||
|
|
|
@ -34,6 +34,7 @@ import java.sql.SQLException;
|
|||
import java.sql.Types;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
@ -1231,9 +1232,19 @@ public abstract class Dialect {
|
|||
* @param lockOptions the lock options to apply
|
||||
* @return The appropriate <tt>FOR UPDATE OF column_list</tt> clause string.
|
||||
*/
|
||||
@SuppressWarnings( {"unchecked"})
|
||||
public String getForUpdateString(String aliases, LockOptions lockOptions) {
|
||||
// by default we simply return the getForUpdateString() result since
|
||||
// the default is to say no support for "FOR UPDATE OF ..."
|
||||
LockMode lockMode = lockOptions.getLockMode();
|
||||
Iterator<Map.Entry<String, LockMode>> itr = lockOptions.getAliasLockIterator();
|
||||
while ( itr.hasNext() ) {
|
||||
// seek the highest lock mode
|
||||
final Map.Entry<String, LockMode>entry = itr.next();
|
||||
final LockMode lm = entry.getValue();
|
||||
if ( lm.greaterThan(lockMode) ) {
|
||||
lockMode = lm;
|
||||
}
|
||||
}
|
||||
lockOptions.setLockMode( lockMode );
|
||||
return getForUpdateString( lockOptions );
|
||||
}
|
||||
|
||||
|
@ -1252,7 +1263,7 @@ public abstract class Dialect {
|
|||
* for this dialect given the aliases of the columns to be write locked.
|
||||
*
|
||||
* @param aliases The columns to be write locked.
|
||||
* @return The appropriate <tt>FOR UPDATE colunm_list NOWAIT</tt> clause string.
|
||||
* @return The appropriate <tt>FOR UPDATE OF colunm_list NOWAIT</tt> clause string.
|
||||
*/
|
||||
public String getForUpdateNowaitString(String aliases) {
|
||||
return getForUpdateString( aliases );
|
||||
|
|
|
@ -75,7 +75,6 @@ public class LockModeTest extends BaseCoreFunctionalTestCase {
|
|||
session.close();
|
||||
}
|
||||
|
||||
// @Test( timeout = 6000 )
|
||||
@Test
|
||||
@SuppressWarnings( {"deprecation"})
|
||||
public void testLoading() {
|
||||
|
@ -98,7 +97,6 @@ public class LockModeTest extends BaseCoreFunctionalTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
@FailureExpected( jiraKey = "HHH-5275" )
|
||||
public void testLegacyCriteria() {
|
||||
// open a session, begin a transaction and lock row
|
||||
Session s1 = sessionFactory().openSession();
|
||||
|
@ -121,7 +119,6 @@ public class LockModeTest extends BaseCoreFunctionalTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
@FailureExpected( jiraKey = "HHH-5275" )
|
||||
public void testLegacyCriteriaAliasSpecific() {
|
||||
// open a session, begin a transaction and lock row
|
||||
Session s1 = sessionFactory().openSession();
|
||||
|
@ -144,7 +141,6 @@ public class LockModeTest extends BaseCoreFunctionalTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
@FailureExpected( jiraKey = "HHH-5275" )
|
||||
public void testQuery() {
|
||||
// open a session, begin a transaction and lock row
|
||||
Session s1 = sessionFactory().openSession();
|
||||
|
|
Loading…
Reference in New Issue