HHH-10149 - Fix PostgreSQL Dialect getForUpdateString(String aliases, LockOptions lockOptions) returning a wrong value for update String when aliases is an empty String
This commit is contained in:
parent
4428e1a4c4
commit
a58a866e67
|
@ -7,6 +7,7 @@
|
||||||
package org.hibernate.dialect;
|
package org.hibernate.dialect;
|
||||||
|
|
||||||
import org.hibernate.JDBCException;
|
import org.hibernate.JDBCException;
|
||||||
|
import org.hibernate.LockMode;
|
||||||
import org.hibernate.LockOptions;
|
import org.hibernate.LockOptions;
|
||||||
import org.hibernate.PessimisticLockException;
|
import org.hibernate.PessimisticLockException;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
|
@ -41,6 +42,8 @@ import java.sql.CallableStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An SQL dialect for Postgres
|
* An SQL dialect for Postgres
|
||||||
|
@ -277,7 +280,19 @@ public class PostgreSQL81Dialect extends Dialect {
|
||||||
/*
|
/*
|
||||||
* Parent's implementation for (aliases, lockOptions) ignores aliases.
|
* Parent's implementation for (aliases, lockOptions) ignores aliases.
|
||||||
*/
|
*/
|
||||||
return getForUpdateString(aliases);
|
if ( "".equals( aliases ) ) {
|
||||||
|
LockMode lockMode = lockOptions.getLockMode();
|
||||||
|
final 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 ) ) {
|
||||||
|
aliases = entry.getKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return getForUpdateString( aliases );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue