HHH-15046: fix nullptr problem with db2z/i dialect intialization
This commit is contained in:
parent
b2c29f9ba1
commit
d9bae6f31e
|
@ -33,8 +33,6 @@ import org.hibernate.sql.exec.spi.JdbcOperation;
|
|||
*/
|
||||
public class DB2iDialect extends DB2Dialect {
|
||||
|
||||
private final DatabaseVersion version;
|
||||
|
||||
public DB2iDialect(DialectResolutionInfo info) {
|
||||
this( info.makeCopy() );
|
||||
registerKeywords( info );
|
||||
|
@ -45,17 +43,12 @@ public class DB2iDialect extends DB2Dialect {
|
|||
}
|
||||
|
||||
public DB2iDialect(DatabaseVersion version) {
|
||||
super();
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public DatabaseVersion getIVersion() {
|
||||
return version;
|
||||
super(version);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected UniqueDelegate createUniqueDelegate() {
|
||||
return getIVersion().isSameOrAfter(7, 3)
|
||||
return getVersion().isSameOrAfter(7, 3)
|
||||
? new DefaultUniqueDelegate(this)
|
||||
: super.createUniqueDelegate();
|
||||
}
|
||||
|
@ -65,13 +58,13 @@ public class DB2iDialect extends DB2Dialect {
|
|||
*/
|
||||
@Override
|
||||
public SequenceSupport getSequenceSupport() {
|
||||
return getIVersion().isSameOrAfter(7, 3)
|
||||
return getVersion().isSameOrAfter(7, 3)
|
||||
? DB2iSequenceSupport.INSTANCE : NoSequenceSupport.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuerySequencesString() {
|
||||
if ( getIVersion().isSameOrAfter(7,3) ) {
|
||||
if ( getVersion().isSameOrAfter(7,3) ) {
|
||||
return "select distinct sequence_name from qsys2.syssequences " +
|
||||
"where current_schema='*LIBL' and sequence_schema in (select schema_name from qsys2.library_list_info) " +
|
||||
"or sequence_schema=current_schema";
|
||||
|
@ -83,13 +76,13 @@ public class DB2iDialect extends DB2Dialect {
|
|||
|
||||
@Override
|
||||
public LimitHandler getLimitHandler() {
|
||||
return getIVersion().isSameOrAfter(7, 3)
|
||||
return getVersion().isSameOrAfter(7, 3)
|
||||
? FetchLimitHandler.INSTANCE : LegacyDB2LimitHandler.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IdentityColumnSupport getIdentityColumnSupport() {
|
||||
return getIVersion().isSameOrAfter(7, 3)
|
||||
return getVersion().isSameOrAfter(7, 3)
|
||||
? new DB2IdentityColumnSupport()
|
||||
: new DB2390IdentityColumnSupport();
|
||||
}
|
||||
|
@ -101,7 +94,7 @@ public class DB2iDialect extends DB2Dialect {
|
|||
|
||||
@Override
|
||||
public boolean supportsLateral() {
|
||||
return getIVersion().isSameOrAfter( 7, 1 );
|
||||
return getVersion().isSameOrAfter( 7, 1 );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -110,7 +103,7 @@ public class DB2iDialect extends DB2Dialect {
|
|||
@Override
|
||||
protected <T extends JdbcOperation> SqlAstTranslator<T> buildTranslator(
|
||||
SessionFactoryImplementor sessionFactory, Statement statement) {
|
||||
return new DB2iSqlAstTranslator<>( sessionFactory, statement, version );
|
||||
return new DB2iSqlAstTranslator<>( sessionFactory, statement, getVersion() );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -35,8 +35,6 @@ import static org.hibernate.type.SqlTypes.TIMESTAMP_WITH_TIMEZONE;
|
|||
*/
|
||||
public class DB2zDialect extends DB2Dialect {
|
||||
|
||||
private final DatabaseVersion version;
|
||||
|
||||
public DB2zDialect(DialectResolutionInfo info) {
|
||||
this( info.makeCopy() );
|
||||
registerKeywords( info );
|
||||
|
@ -47,14 +45,13 @@ public class DB2zDialect extends DB2Dialect {
|
|||
}
|
||||
|
||||
public DB2zDialect(DatabaseVersion version) {
|
||||
super();
|
||||
this.version = version;
|
||||
super(version);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String columnType(int jdbcTypeCode) {
|
||||
// See https://www.ibm.com/support/knowledgecenter/SSEPEK_10.0.0/wnew/src/tpc/db2z_10_timestamptimezone.html
|
||||
if ( jdbcTypeCode==TIMESTAMP_WITH_TIMEZONE && version.isAfter(10) ) {
|
||||
if ( jdbcTypeCode==TIMESTAMP_WITH_TIMEZONE && getVersion().isAfter(10) ) {
|
||||
return "timestamp with time zone";
|
||||
}
|
||||
return super.columnType(jdbcTypeCode);
|
||||
|
@ -62,28 +59,24 @@ public class DB2zDialect extends DB2Dialect {
|
|||
|
||||
@Override
|
||||
public TimeZoneSupport getTimeZoneSupport() {
|
||||
return getZVersion().isAfter(10) ? TimeZoneSupport.NATIVE : TimeZoneSupport.NONE;
|
||||
}
|
||||
|
||||
DatabaseVersion getZVersion() {
|
||||
return version;
|
||||
return getVersion().isAfter(10) ? TimeZoneSupport.NATIVE : TimeZoneSupport.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SequenceSupport getSequenceSupport() {
|
||||
return getZVersion().isBefore(8)
|
||||
return getVersion().isBefore(8)
|
||||
? NoSequenceSupport.INSTANCE
|
||||
: DB2zSequenceSupport.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuerySequencesString() {
|
||||
return getZVersion().isBefore(8) ? null : "select * from sysibm.syssequences";
|
||||
return getVersion().isBefore(8) ? null : "select * from sysibm.syssequences";
|
||||
}
|
||||
|
||||
@Override
|
||||
public LimitHandler getLimitHandler() {
|
||||
return getZVersion().isBefore(12)
|
||||
return getVersion().isBefore(12)
|
||||
? FetchLimitHandler.INSTANCE
|
||||
: OffsetFetchLimitHandler.INSTANCE;
|
||||
}
|
||||
|
@ -160,7 +153,7 @@ public class DB2zDialect extends DB2Dialect {
|
|||
@Override
|
||||
protected <T extends JdbcOperation> SqlAstTranslator<T> buildTranslator(
|
||||
SessionFactoryImplementor sessionFactory, Statement statement) {
|
||||
return new DB2zSqlAstTranslator<>( sessionFactory, statement, version );
|
||||
return new DB2zSqlAstTranslator<>( sessionFactory, statement, getVersion() );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue