HHH-18560: fix for invalid queries executed on DB2i AS/400 machine

This commit is contained in:
Alex 2024-09-04 16:29:14 +02:00 committed by Marco Belladelli
parent c8ec156456
commit b91d988683
No known key found for this signature in database
GPG Key ID: DBD6E257ABE9EA3D
2 changed files with 41 additions and 0 deletions

View File

@ -6,6 +6,7 @@
*/
package org.hibernate.dialect;
import org.hibernate.LockOptions;
import org.hibernate.boot.model.FunctionContributions;
import org.hibernate.dialect.function.CommonFunctionFactory;
import org.hibernate.dialect.identity.DB2IdentityColumnSupport;
@ -41,6 +42,9 @@ public class DB2iDialect extends DB2Dialect {
private final static DatabaseVersion MINIMUM_VERSION = DatabaseVersion.make( 7, 1 );
final static DatabaseVersion DB2_LUW_VERSION = DB2Dialect.MINIMUM_VERSION;
private static final String FOR_UPDATE_SQL = " for update with rs";
private static final String FOR_UPDATE_SKIP_LOCKED_SQL = FOR_UPDATE_SQL + " skip locked data";
public DB2iDialect(DialectResolutionInfo info) {
this( info.makeCopyOrDefault( MINIMUM_VERSION ) );
registerKeywords( info );
@ -124,6 +128,7 @@ public class DB2iDialect extends DB2Dialect {
}
}
@Override
public LimitHandler getLimitHandler() {
return getVersion().isSameOrAfter(7, 3)
@ -171,4 +176,35 @@ public class DB2iDialect extends DB2Dialect {
public String getRowIdColumnString(String rowId) {
return rowId( rowId ) + " rowid not null generated always";
}
@Override
public String getForUpdateString() {
return FOR_UPDATE_SQL;
}
@Override
public String getForUpdateSkipLockedString() {
return supportsSkipLocked()
? FOR_UPDATE_SKIP_LOCKED_SQL
: FOR_UPDATE_SQL;
}
@Override
public String getForUpdateSkipLockedString(String aliases) {
return getForUpdateSkipLockedString();
}
@Override
public String getWriteLockString(int timeout) {
return timeout == LockOptions.SKIP_LOCKED && supportsSkipLocked()
? FOR_UPDATE_SKIP_LOCKED_SQL
: FOR_UPDATE_SQL;
}
@Override
public String getReadLockString(int timeout) {
return timeout == LockOptions.SKIP_LOCKED && supportsSkipLocked()
? FOR_UPDATE_SKIP_LOCKED_SQL
: FOR_UPDATE_SQL;
}
}

View File

@ -60,4 +60,9 @@ public class DB2iSqlAstTranslator<T extends JdbcOperation> extends DB2SqlAstTran
public DatabaseVersion getDB2Version() {
return DB2_LUW_VERSION;
}
@Override
protected String getForUpdate() {
return " for update with rs";
}
}