Handle keywords initialization for dialects through DialectResolutionInfo and un-deprecate Dialect#getKeywords
This commit is contained in:
parent
ae9d99a32c
commit
98de63d0a1
|
@ -19,6 +19,7 @@ import org.hibernate.dialect.pagination.LimitLimitHandler;
|
|||
import org.hibernate.community.dialect.sequence.CUBRIDSequenceSupport;
|
||||
import org.hibernate.dialect.sequence.SequenceSupport;
|
||||
import org.hibernate.engine.jdbc.Size;
|
||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.query.IntervalType;
|
||||
import org.hibernate.query.SemanticException;
|
||||
|
@ -103,6 +104,11 @@ public class CUBRIDDialect extends Dialect {
|
|||
registerKeyword( "SEARCH" );
|
||||
}
|
||||
|
||||
public CUBRIDDialect(DialectResolutionInfo info) {
|
||||
this();
|
||||
registerKeywords( info );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVersion() {
|
||||
return 0;
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.hibernate.dialect.pagination.LimitHandler;
|
|||
import org.hibernate.dialect.pagination.TopLimitHandler;
|
||||
import org.hibernate.community.dialect.sequence.CacheSequenceSupport;
|
||||
import org.hibernate.dialect.sequence.SequenceSupport;
|
||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.exception.ConstraintViolationException;
|
||||
import org.hibernate.exception.DataException;
|
||||
|
@ -75,6 +76,11 @@ public class CacheDialect extends Dialect {
|
|||
getDefaultProperties().setProperty( Environment.USE_SQL_COMMENTS, "false" );
|
||||
}
|
||||
|
||||
public CacheDialect(DialectResolutionInfo info) {
|
||||
this();
|
||||
registerKeywords( info );
|
||||
}
|
||||
|
||||
private static void useJdbcEscape(QueryEngine queryEngine, String name) {
|
||||
//Yep, this seems to be truly necessary for certain functions
|
||||
queryEngine.getSqmFunctionRegistry().wrapInJdbcEscape(
|
||||
|
|
|
@ -89,7 +89,7 @@ public enum CommunityDatabase {
|
|||
CACHE {
|
||||
@Override
|
||||
public Dialect createDialect(DialectResolutionInfo info) {
|
||||
return new CacheDialect();
|
||||
return new CacheDialect( info );
|
||||
}
|
||||
@Override
|
||||
public boolean productNameMatches(String databaseName) {
|
||||
|
@ -100,7 +100,7 @@ public enum CommunityDatabase {
|
|||
CUBRID {
|
||||
@Override
|
||||
public Dialect createDialect(DialectResolutionInfo info) {
|
||||
return new CUBRIDDialect();
|
||||
return new CUBRIDDialect( info );
|
||||
}
|
||||
@Override
|
||||
public boolean productNameMatches(String databaseName) {
|
||||
|
@ -115,7 +115,7 @@ public enum CommunityDatabase {
|
|||
MIMER {
|
||||
@Override
|
||||
public Dialect createDialect(DialectResolutionInfo info) {
|
||||
return new MimerSQLDialect();
|
||||
return new MimerSQLDialect( info );
|
||||
}
|
||||
@Override
|
||||
public boolean productNameMatches(String databaseName) {
|
||||
|
@ -130,7 +130,7 @@ public enum CommunityDatabase {
|
|||
MAXDB {
|
||||
@Override
|
||||
public Dialect createDialect(DialectResolutionInfo info) {
|
||||
return new MaxDBDialect();
|
||||
return new MaxDBDialect( info );
|
||||
}
|
||||
@Override
|
||||
public boolean productNameMatches(String databaseName) {
|
||||
|
@ -189,7 +189,7 @@ public enum CommunityDatabase {
|
|||
TIMESTEN {
|
||||
@Override
|
||||
public Dialect createDialect(DialectResolutionInfo info) {
|
||||
return new TimesTenDialect();
|
||||
return new TimesTenDialect( info );
|
||||
}
|
||||
@Override
|
||||
public boolean productNameMatches(String databaseName) {
|
||||
|
|
|
@ -98,6 +98,7 @@ public class FirebirdDialect extends Dialect {
|
|||
|
||||
public FirebirdDialect(DialectResolutionInfo info) {
|
||||
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10 );
|
||||
registerKeywords( info );
|
||||
}
|
||||
|
||||
// KNOWN LIMITATIONS:
|
||||
|
|
|
@ -67,14 +67,14 @@ import static org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtract
|
|||
public class InformixDialect extends Dialect {
|
||||
|
||||
private final int version;
|
||||
private final UniqueDelegate uniqueDelegate;
|
||||
private final LimitHandler limitHandler;
|
||||
|
||||
public InformixDialect(DialectResolutionInfo info) {
|
||||
this( info.getDatabaseMajorVersion() );
|
||||
registerKeywords( info );
|
||||
}
|
||||
|
||||
private final UniqueDelegate uniqueDelegate;
|
||||
private final LimitHandler limitHandler;
|
||||
|
||||
public InformixDialect() {
|
||||
this( 7 );
|
||||
}
|
||||
|
|
|
@ -93,6 +93,7 @@ public class IngresDialect extends Dialect {
|
|||
|
||||
public IngresDialect(DialectResolutionInfo info) {
|
||||
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10 );
|
||||
registerKeywords( info );
|
||||
}
|
||||
|
||||
public IngresDialect() {
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.hibernate.dialect.pagination.LimitHandler;
|
|||
import org.hibernate.dialect.pagination.LimitOffsetLimitHandler;
|
||||
import org.hibernate.community.dialect.sequence.MaxDBSequenceSupport;
|
||||
import org.hibernate.dialect.sequence.SequenceSupport;
|
||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.metamodel.mapping.EntityMappingType;
|
||||
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
||||
|
@ -87,6 +88,11 @@ public class MaxDBDialect extends Dialect {
|
|||
);
|
||||
}
|
||||
|
||||
public MaxDBDialect(DialectResolutionInfo info) {
|
||||
this();
|
||||
registerKeywords( info );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVersion() {
|
||||
return 0;
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.hibernate.dialect.pagination.OffsetFetchLimitHandler;
|
|||
import org.hibernate.community.dialect.sequence.MimerSequenceSupport;
|
||||
import org.hibernate.dialect.sequence.SequenceSupport;
|
||||
import org.hibernate.engine.jdbc.Size;
|
||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.query.IntervalType;
|
||||
import org.hibernate.query.SemanticException;
|
||||
|
@ -79,6 +80,11 @@ public class MimerSQLDialect extends Dialect {
|
|||
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, "50" );
|
||||
}
|
||||
|
||||
public MimerSQLDialect(DialectResolutionInfo info) {
|
||||
this();
|
||||
registerKeywords( info );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName(int code, Size size) throws HibernateException {
|
||||
//precision of a Mimer 'float(p)' represents
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.hibernate.dialect.pagination.FetchLimitHandler;
|
|||
import org.hibernate.dialect.pagination.LimitHandler;
|
||||
import org.hibernate.community.dialect.sequence.RDMSSequenceSupport;
|
||||
import org.hibernate.dialect.sequence.SequenceSupport;
|
||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.persister.entity.Lockable;
|
||||
|
@ -107,6 +108,11 @@ public class RDMSOS2200Dialect extends Dialect {
|
|||
registerColumnType( Types.TIMESTAMP_WITH_TIMEZONE, "timestamp($p)");
|
||||
}
|
||||
|
||||
public RDMSOS2200Dialect(DialectResolutionInfo info) {
|
||||
this();
|
||||
registerKeywords( info );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVersion() {
|
||||
return 0;
|
||||
|
|
|
@ -83,6 +83,7 @@ public class SQLiteDialect extends Dialect {
|
|||
|
||||
public SQLiteDialect(DialectResolutionInfo info) {
|
||||
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() );
|
||||
registerKeywords( info );
|
||||
}
|
||||
|
||||
public SQLiteDialect() {
|
||||
|
|
|
@ -42,6 +42,7 @@ public class SybaseAnywhereDialect extends SybaseDialect {
|
|||
info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10,
|
||||
info.getDriverName() != null && info.getDriverName().contains( "jTDS" )
|
||||
);
|
||||
registerKeywords( info );
|
||||
}
|
||||
|
||||
public SybaseAnywhereDialect(int version, boolean jtdsDriver) {
|
||||
|
|
|
@ -75,6 +75,7 @@ public class TeradataDialect extends Dialect {
|
|||
|
||||
public TeradataDialect(DialectResolutionInfo info) {
|
||||
this( info.getDatabaseMajorVersion() );
|
||||
registerKeywords( info );
|
||||
}
|
||||
|
||||
public TeradataDialect() {
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.hibernate.dialect.pagination.LimitHandler;
|
|||
import org.hibernate.community.dialect.pagination.TimesTenLimitHandler;
|
||||
import org.hibernate.dialect.sequence.SequenceSupport;
|
||||
import org.hibernate.community.dialect.sequence.TimesTenSequenceSupport;
|
||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.metamodel.mapping.EntityMappingType;
|
||||
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
||||
|
@ -58,7 +59,6 @@ import jakarta.persistence.TemporalType;
|
|||
*
|
||||
* @author Sherry Listgarten, Max Andersen, Chris Jenkins
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class TimesTenDialect extends Dialect {
|
||||
|
||||
public TimesTenDialect() {
|
||||
|
@ -96,6 +96,11 @@ public class TimesTenDialect extends Dialect {
|
|||
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
|
||||
}
|
||||
|
||||
public TimesTenDialect(DialectResolutionInfo info) {
|
||||
this();
|
||||
registerKeywords( info );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVersion() {
|
||||
return 0;
|
||||
|
|
|
@ -444,7 +444,7 @@ public interface AvailableSettings {
|
|||
* @see #DIALECT_DB_MAJOR_VERSION
|
||||
* @see #DIALECT_DB_MINOR_VERSION
|
||||
*
|
||||
* @deprecated Use {@link #JAKARTA_HBM2DDL_DB_VERSION} instead
|
||||
* @deprecated Use {@link #JAKARTA_HBM2DDL_DB_NAME} instead
|
||||
*/
|
||||
@Deprecated
|
||||
String DIALECT_DB_NAME = "javax.persistence.database-product-name";
|
||||
|
@ -459,7 +459,10 @@ public interface AvailableSettings {
|
|||
* {@link java.sql.DatabaseMetaData#getDatabaseProductVersion()} for the target database.
|
||||
*
|
||||
* @see #DIALECT_DB_NAME
|
||||
*
|
||||
* @deprecated Use {@link #JAKARTA_HBM2DDL_DB_VERSION} instead
|
||||
*/
|
||||
@Deprecated
|
||||
String DIALECT_DB_VERSION = "javax.persistence.database-product-version";
|
||||
|
||||
/**
|
||||
|
@ -470,7 +473,10 @@ public interface AvailableSettings {
|
|||
|
||||
* @see #DIALECT_DB_NAME
|
||||
* @see #DIALECT_DB_MINOR_VERSION
|
||||
*
|
||||
* @deprecated Use {@link #JAKARTA_HBM2DDL_DB_MAJOR_VERSION} instead
|
||||
*/
|
||||
@Deprecated
|
||||
String DIALECT_DB_MAJOR_VERSION = "javax.persistence.database-major-version";
|
||||
|
||||
/**
|
||||
|
@ -482,7 +488,10 @@ public interface AvailableSettings {
|
|||
* @see #DIALECT_DB_NAME
|
||||
* @see #DIALECT_DB_MAJOR_VERSION
|
||||
* @see DialectResolver
|
||||
*
|
||||
* @deprecated Use {@link #JAKARTA_HBM2DDL_DB_MINOR_VERSION} instead
|
||||
*/
|
||||
@Deprecated
|
||||
String DIALECT_DB_MINOR_VERSION = "javax.persistence.database-minor-version";
|
||||
|
||||
/**
|
||||
|
|
|
@ -1194,24 +1194,13 @@ public abstract class AbstractHANADialect extends Dialect {
|
|||
@Override
|
||||
public IdentifierHelper buildIdentifierHelper(IdentifierHelperBuilder builder, DatabaseMetaData dbMetaData)
|
||||
throws SQLException {
|
||||
/*
|
||||
* Copied from Dialect
|
||||
*/
|
||||
builder.applyIdentifierCasing( dbMetaData );
|
||||
|
||||
builder.applyReservedWords( dbMetaData );
|
||||
builder.applyReservedWords( AnsiSqlKeywords.INSTANCE.sql2003() );
|
||||
builder.applyReservedWords( getKeywords() );
|
||||
|
||||
builder.setNameQualifierSupport( getNameQualifierSupport() );
|
||||
|
||||
/*
|
||||
* HANA-specific extensions
|
||||
*/
|
||||
builder.setQuotedCaseStrategy( IdentifierCaseStrategy.MIXED );
|
||||
builder.setUnquotedCaseStrategy( IdentifierCaseStrategy.UPPER );
|
||||
|
||||
final IdentifierHelper identifierHelper = builder.build();
|
||||
final IdentifierHelper identifierHelper = super.buildIdentifierHelper( builder, dbMetaData );
|
||||
|
||||
return new IdentifierHelper() {
|
||||
|
||||
|
|
|
@ -82,6 +82,7 @@ public class CockroachDialect extends Dialect {
|
|||
info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10,
|
||||
PostgreSQLDriverKind.determineKind( info )
|
||||
);
|
||||
registerKeywords( info );
|
||||
}
|
||||
|
||||
public CockroachDialect(int version) {
|
||||
|
|
|
@ -79,6 +79,7 @@ public class DB2Dialect extends Dialect {
|
|||
|
||||
public DB2Dialect(DialectResolutionInfo info) {
|
||||
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10 );
|
||||
registerKeywords( info );
|
||||
}
|
||||
|
||||
public DB2Dialect() {
|
||||
|
|
|
@ -37,6 +37,7 @@ public class DB2iDialect extends DB2Dialect {
|
|||
|
||||
public DB2iDialect(DialectResolutionInfo info) {
|
||||
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10 );
|
||||
registerKeywords( info );
|
||||
}
|
||||
|
||||
public DB2iDialect() {
|
||||
|
|
|
@ -38,6 +38,7 @@ public class DB2zDialect extends DB2Dialect {
|
|||
|
||||
public DB2zDialect(DialectResolutionInfo info) {
|
||||
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10 );
|
||||
registerKeywords( info );
|
||||
}
|
||||
|
||||
public DB2zDialect() {
|
||||
|
|
|
@ -241,7 +241,7 @@ public enum Database {
|
|||
SPANNER {
|
||||
@Override
|
||||
public Dialect createDialect(DialectResolutionInfo info) {
|
||||
return new SpannerDialect();
|
||||
return new SpannerDialect( info );
|
||||
}
|
||||
@Override
|
||||
public boolean productNameMatches(String databaseName) {
|
||||
|
|
|
@ -26,8 +26,6 @@ import org.hibernate.dialect.sequence.DerbySequenceSupport;
|
|||
import org.hibernate.dialect.sequence.SequenceSupport;
|
||||
import org.hibernate.engine.jdbc.Size;
|
||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||
import org.hibernate.engine.jdbc.env.spi.IdentifierHelper;
|
||||
import org.hibernate.engine.jdbc.env.spi.IdentifierHelperBuilder;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.exception.LockTimeoutException;
|
||||
import org.hibernate.exception.spi.SQLExceptionConversionDelegate;
|
||||
|
@ -64,8 +62,6 @@ import org.hibernate.type.descriptor.jdbc.SmallIntJdbcType;
|
|||
import org.hibernate.type.descriptor.jdbc.TimestampJdbcType;
|
||||
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeDescriptorRegistry;
|
||||
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
|
||||
import jakarta.persistence.TemporalType;
|
||||
|
@ -98,6 +94,7 @@ public class DerbyDialect extends Dialect {
|
|||
|
||||
public DerbyDialect(DialectResolutionInfo info) {
|
||||
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10 );
|
||||
registerKeywords( info );
|
||||
}
|
||||
|
||||
public DerbyDialect() {
|
||||
|
@ -535,20 +532,6 @@ public class DerbyDialect extends Dialect {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IdentifierHelper buildIdentifierHelper(
|
||||
IdentifierHelperBuilder builder, DatabaseMetaData dbMetaData) throws SQLException {
|
||||
builder.applyIdentifierCasing( dbMetaData );
|
||||
|
||||
builder.applyReservedWords( dbMetaData );
|
||||
|
||||
builder.applyReservedWords( getKeywords() );
|
||||
|
||||
builder.setNameQualifierSupport( getNameQualifierSupport() );
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SQLExceptionConversionDelegate buildSQLExceptionConversionDelegate() {
|
||||
return (sqlException, message, sql) -> {
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.hibernate.LockMode;
|
|||
import org.hibernate.LockOptions;
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.dialect.sequence.NoSequenceSupport;
|
||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||
import org.hibernate.metamodel.mapping.JdbcMapping;
|
||||
import org.hibernate.query.FetchClauseType;
|
||||
import org.hibernate.query.IntervalType;
|
||||
|
@ -237,14 +238,24 @@ public abstract class Dialect implements ConversionContext {
|
|||
registerHibernateType( Types.TIME, StandardBasicTypes.TIME.getName() );
|
||||
registerHibernateType( Types.TIMESTAMP, StandardBasicTypes.TIMESTAMP.getName() );
|
||||
|
||||
if(supportsPartitionBy()) {
|
||||
registerKeyword( "PARTITION" );
|
||||
}
|
||||
registerDefaultKeywords();
|
||||
|
||||
uniqueDelegate = new DefaultUniqueDelegate( this );
|
||||
sizeStrategy = new SizeStrategyImpl();
|
||||
}
|
||||
|
||||
protected void registerDefaultKeywords() {
|
||||
for ( String keyword : AnsiSqlKeywords.INSTANCE.sql2003() ) {
|
||||
registerKeyword( keyword );
|
||||
}
|
||||
}
|
||||
|
||||
protected void registerKeywords(DialectResolutionInfo info) {
|
||||
for ( String keyword : StringHelper.parseCommaSeparatedString( info.getSQLKeywords() ) ) {
|
||||
registerKeyword( keyword );
|
||||
}
|
||||
}
|
||||
|
||||
public JdbcType resolveSqlTypeDescriptor(
|
||||
String columnTypeName,
|
||||
int jdbcTypeCode,
|
||||
|
@ -2136,10 +2147,8 @@ public abstract class Dialect implements ConversionContext {
|
|||
}
|
||||
|
||||
/**
|
||||
* @deprecated These are only ever used (if at all) from the code that handles identifier quoting.
|
||||
* So see {@link #buildIdentifierHelper} instead
|
||||
* The keywords of the SQL dialect
|
||||
*/
|
||||
@Deprecated
|
||||
public Set<String> getKeywords() {
|
||||
return sqlKeywords;
|
||||
}
|
||||
|
@ -2178,8 +2187,6 @@ public abstract class Dialect implements ConversionContext {
|
|||
DatabaseMetaData dbMetaData) throws SQLException {
|
||||
builder.applyIdentifierCasing( dbMetaData );
|
||||
|
||||
builder.applyReservedWords( dbMetaData );
|
||||
builder.applyReservedWords( AnsiSqlKeywords.INSTANCE.sql2003() );
|
||||
builder.applyReservedWords( sqlKeywords );
|
||||
|
||||
builder.setNameQualifierSupport( getNameQualifierSupport() );
|
||||
|
|
|
@ -85,6 +85,15 @@ public class H2Dialect extends Dialect {
|
|||
private final SequenceInformationExtractor sequenceInformationExtractor;
|
||||
private final String querySequenceString;
|
||||
|
||||
public H2Dialect(DialectResolutionInfo info) {
|
||||
this(
|
||||
info.getDatabaseMajorVersion() * 100000
|
||||
+ info.getDatabaseMinorVersion() * 1000,
|
||||
parseBuildId( info )
|
||||
);
|
||||
registerKeywords( info );
|
||||
}
|
||||
|
||||
public H2Dialect() {
|
||||
this(0, 0);
|
||||
}
|
||||
|
@ -160,14 +169,6 @@ public class H2Dialect extends Dialect {
|
|||
return bits.length > 2 ? Integer.parseInt( bits[2] ) : 0;
|
||||
}
|
||||
|
||||
public H2Dialect(DialectResolutionInfo info) {
|
||||
this(
|
||||
info.getDatabaseMajorVersion() * 100000
|
||||
+ info.getDatabaseMinorVersion() * 1000,
|
||||
parseBuildId( info )
|
||||
);
|
||||
}
|
||||
|
||||
public boolean hasDstBug() {
|
||||
// H2 1.4.200 has a bug: https://github.com/h2database/h2database/issues/3184
|
||||
return getVersion() == 104200;
|
||||
|
|
|
@ -38,6 +38,7 @@ public class HANAColumnStoreDialect extends AbstractHANADialect {
|
|||
|
||||
public HANAColumnStoreDialect(DialectResolutionInfo info) {
|
||||
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10 );
|
||||
registerKeywords( info );
|
||||
}
|
||||
|
||||
public HANAColumnStoreDialect() {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
package org.hibernate.dialect;
|
||||
|
||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||
import org.hibernate.metamodel.mapping.EntityMappingType;
|
||||
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
||||
import org.hibernate.query.sqm.mutation.internal.idtable.AfterUseAction;
|
||||
|
@ -34,6 +35,11 @@ public class HANARowStoreDialect extends AbstractHANADialect {
|
|||
super();
|
||||
}
|
||||
|
||||
public HANARowStoreDialect(DialectResolutionInfo info) {
|
||||
super();
|
||||
registerKeywords( info );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCreateTableString() {
|
||||
return "create row table";
|
||||
|
|
|
@ -88,6 +88,7 @@ public class HSQLDialect extends Dialect {
|
|||
|
||||
public HSQLDialect(DialectResolutionInfo info) {
|
||||
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10 );
|
||||
registerKeywords( info );
|
||||
}
|
||||
|
||||
public HSQLDialect() {
|
||||
|
|
|
@ -46,6 +46,7 @@ public class MariaDBDialect extends MySQLDialect {
|
|||
info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10,
|
||||
getCharacterSetBytesPerCharacter( info.unwrap( DatabaseMetaData.class ) )
|
||||
);
|
||||
registerKeywords( info );
|
||||
}
|
||||
|
||||
public MariaDBDialect(int version) {
|
||||
|
|
|
@ -93,6 +93,7 @@ public class MySQLDialect extends Dialect {
|
|||
info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10,
|
||||
getCharacterSetBytesPerCharacter( info.unwrap( DatabaseMetaData.class ) )
|
||||
);
|
||||
registerKeywords( info );
|
||||
}
|
||||
|
||||
public MySQLDialect() {
|
||||
|
|
|
@ -89,27 +89,22 @@ import static org.hibernate.query.TemporalUnit.*;
|
|||
*/
|
||||
public class OracleDialect extends Dialect {
|
||||
|
||||
private final int version;
|
||||
|
||||
public OracleDialect(DialectResolutionInfo info) {
|
||||
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() );
|
||||
}
|
||||
|
||||
private static final Pattern DISTINCT_KEYWORD_PATTERN = Pattern.compile( "\\bdistinct\\b" );
|
||||
|
||||
private static final Pattern GROUP_BY_KEYWORD_PATTERN = Pattern.compile( "\\bgroup\\sby\\b" );
|
||||
|
||||
private static final Pattern ORDER_BY_KEYWORD_PATTERN = Pattern.compile( "\\border\\sby\\b" );
|
||||
|
||||
private static final Pattern UNION_KEYWORD_PATTERN = Pattern.compile( "\\bunion\\b" );
|
||||
|
||||
private static final Pattern SQL_STATEMENT_TYPE_PATTERN = Pattern.compile("^(?:/\\*.*?\\*/)?\\s*(select|insert|update|delete)\\s+.*?");
|
||||
|
||||
private static final int PARAM_LIST_SIZE_LIMIT = 1000;
|
||||
|
||||
public static final String PREFER_LONG_RAW = "hibernate.dialect.oracle.prefer_long_raw";
|
||||
|
||||
private final LimitHandler limitHandler;
|
||||
private final int version;
|
||||
|
||||
public OracleDialect(DialectResolutionInfo info) {
|
||||
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() );
|
||||
registerKeywords( info );
|
||||
}
|
||||
|
||||
public OracleDialect() {
|
||||
this( 800 );
|
||||
|
|
|
@ -100,6 +100,7 @@ public class PostgreSQLDialect extends Dialect {
|
|||
info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10,
|
||||
PostgreSQLDriverKind.determineKind( info )
|
||||
);
|
||||
registerKeywords( info );
|
||||
}
|
||||
|
||||
public PostgreSQLDialect() {
|
||||
|
|
|
@ -85,6 +85,7 @@ public class SQLServerDialect extends AbstractTransactSQLDialect {
|
|||
|
||||
public SQLServerDialect(DialectResolutionInfo info) {
|
||||
this( info.getDatabaseMajorVersion() );
|
||||
registerKeywords( info );
|
||||
}
|
||||
|
||||
public SQLServerDialect() {
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.hibernate.dialect.lock.LockingStrategyException;
|
|||
import org.hibernate.dialect.pagination.LimitHandler;
|
||||
import org.hibernate.dialect.pagination.LimitOffsetLimitHandler;
|
||||
import org.hibernate.dialect.unique.UniqueDelegate;
|
||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||
import org.hibernate.engine.jdbc.env.spi.SchemaNameResolver;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
|
@ -104,6 +105,11 @@ public class SpannerDialect extends Dialect {
|
|||
registerColumnType( Types.BLOB, "bytes(max)" );
|
||||
}
|
||||
|
||||
public SpannerDialect(DialectResolutionInfo info) {
|
||||
this();
|
||||
registerKeywords( info );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVersion() {
|
||||
return 0;
|
||||
|
|
|
@ -63,6 +63,7 @@ public class SybaseASEDialect extends SybaseDialect {
|
|||
info.getDriverName() != null && info.getDriverName().contains( "jTDS" ),
|
||||
isAnsiNull( info.unwrap( DatabaseMetaData.class ) )
|
||||
);
|
||||
registerKeywords( info );
|
||||
}
|
||||
|
||||
public SybaseASEDialect(int version, boolean jtdsDriver, boolean ansiNull) {
|
||||
|
|
|
@ -75,6 +75,7 @@ public class SybaseDialect extends AbstractTransactSQLDialect {
|
|||
info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10,
|
||||
info.getDriverName() != null && info.getDriverName().contains( "jTDS" )
|
||||
);
|
||||
registerKeywords( info );
|
||||
}
|
||||
|
||||
public SybaseDialect(int version, boolean jtdsDriver) {
|
||||
|
|
|
@ -88,6 +88,16 @@ public class DatabaseMetaDataDialectResolutionInfoAdapter implements DialectReso
|
|||
return interpretVersion( databaseMetaData.getDriverMinorVersion() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLKeywords() {
|
||||
try {
|
||||
return databaseMetaData.getSQLKeywords();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw BasicSQLExceptionConverter.INSTANCE.convert( e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T unwrap(Class<T> clazz) {
|
||||
if ( clazz.isInstance( databaseMetaData ) ) {
|
||||
|
|
|
@ -89,6 +89,16 @@ public interface DialectResolutionInfo {
|
|||
*/
|
||||
int getDriverMinorVersion();
|
||||
|
||||
/**
|
||||
* Obtain access to the SQL keywords of the JDBC driver, as returned from
|
||||
* {@link java.sql.DatabaseMetaData#getSQLKeywords()} for the target database.
|
||||
*
|
||||
* @return The JDBC driver keywords
|
||||
*
|
||||
* @see java.sql.DatabaseMetaData#getSQLKeywords()
|
||||
*/
|
||||
String getSQLKeywords();
|
||||
|
||||
/**
|
||||
* Obtain access to the underlying object of the given type.
|
||||
*
|
||||
|
|
|
@ -58,7 +58,7 @@ public class JdbcEnvironmentInitiator implements StandardServiceInitiator<JdbcEn
|
|||
// it is used to control whether we should consult the JDBC metadata to determine
|
||||
// certain Settings default values; it is useful to *not* do this when the database
|
||||
// may not be available (mainly in tools usage).
|
||||
boolean useJdbcMetadata = ConfigurationHelper.getBoolean(
|
||||
final boolean useJdbcMetadata = ConfigurationHelper.getBoolean(
|
||||
"hibernate.temp.use_jdbc_metadata_defaults",
|
||||
configurationValues,
|
||||
true
|
||||
|
@ -78,12 +78,55 @@ public class JdbcEnvironmentInitiator implements StandardServiceInitiator<JdbcEn
|
|||
}
|
||||
);
|
||||
|
||||
NullnessHelper.coalesceSuppliedValues(
|
||||
() -> AvailableSettings.JAKARTA_HBM2DDL_DB_VERSION,
|
||||
() -> AvailableSettings.DIALECT_DB_VERSION
|
||||
);
|
||||
|
||||
if ( dbName != null ) {
|
||||
final String dbVersion = NullnessHelper.coalesceSuppliedValues(
|
||||
() -> (String) configurationValues.get( AvailableSettings.JAKARTA_HBM2DDL_DB_VERSION ),
|
||||
() -> {
|
||||
final Object value = configurationValues.get( AvailableSettings.DIALECT_DB_VERSION );
|
||||
if ( value != null ) {
|
||||
DeprecationLogger.DEPRECATION_LOGGER.deprecatedSetting(
|
||||
AvailableSettings.DIALECT_DB_VERSION,
|
||||
AvailableSettings.JAKARTA_HBM2DDL_DB_VERSION
|
||||
);
|
||||
}
|
||||
return (String) value;
|
||||
},
|
||||
() -> "0"
|
||||
);
|
||||
final int dbMajorVersion = NullnessHelper.coalesceSuppliedValues(
|
||||
() -> ConfigurationHelper.getInteger( AvailableSettings.JAKARTA_HBM2DDL_DB_MAJOR_VERSION, configurationValues ),
|
||||
() -> {
|
||||
final Integer value = ConfigurationHelper.getInteger(
|
||||
AvailableSettings.DIALECT_DB_MAJOR_VERSION,
|
||||
configurationValues
|
||||
);
|
||||
if ( value != null ) {
|
||||
DeprecationLogger.DEPRECATION_LOGGER.deprecatedSetting(
|
||||
AvailableSettings.DIALECT_DB_MAJOR_VERSION,
|
||||
AvailableSettings.JAKARTA_HBM2DDL_DB_MAJOR_VERSION
|
||||
);
|
||||
}
|
||||
return value;
|
||||
},
|
||||
() -> 0
|
||||
);
|
||||
final int dbMinorVersion = NullnessHelper.coalesceSuppliedValues(
|
||||
() -> ConfigurationHelper.getInteger( AvailableSettings.JAKARTA_HBM2DDL_DB_MINOR_VERSION, configurationValues ),
|
||||
() -> {
|
||||
final Integer value = ConfigurationHelper.getInteger(
|
||||
AvailableSettings.DIALECT_DB_MINOR_VERSION,
|
||||
configurationValues
|
||||
);
|
||||
if ( value != null ) {
|
||||
DeprecationLogger.DEPRECATION_LOGGER.deprecatedSetting(
|
||||
AvailableSettings.DIALECT_DB_MINOR_VERSION,
|
||||
AvailableSettings.JAKARTA_HBM2DDL_DB_MINOR_VERSION
|
||||
);
|
||||
}
|
||||
return value;
|
||||
},
|
||||
() -> 0
|
||||
);
|
||||
return new JdbcEnvironmentImpl( registry, dialectFactory.buildDialect(
|
||||
configurationValues,
|
||||
() -> new DialectResolutionInfo() {
|
||||
|
@ -94,32 +137,37 @@ public class JdbcEnvironmentInitiator implements StandardServiceInitiator<JdbcEn
|
|||
|
||||
@Override
|
||||
public String getDatabaseVersion() {
|
||||
return (String) configurationValues.getOrDefault( AvailableSettings.DIALECT_DB_VERSION, "0" );
|
||||
return dbVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDatabaseMajorVersion() {
|
||||
return (Integer) configurationValues.getOrDefault( AvailableSettings.DIALECT_DB_MAJOR_VERSION, 0 );
|
||||
return dbMajorVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDatabaseMinorVersion() {
|
||||
return (Integer) configurationValues.getOrDefault( AvailableSettings.DIALECT_DB_MINOR_VERSION, 0 );
|
||||
return dbMinorVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverName() {
|
||||
throw new UnsupportedOperationException();
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDriverMajorVersion() {
|
||||
throw new UnsupportedOperationException();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDriverMinorVersion() {
|
||||
throw new UnsupportedOperationException();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLKeywords() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
) );
|
||||
|
@ -156,7 +204,7 @@ public class JdbcEnvironmentInitiator implements StandardServiceInitiator<JdbcEn
|
|||
log.debugf( "JDBC version : %s.%s", dbmd.getJDBCMajorVersion(), dbmd.getJDBCMinorVersion() );
|
||||
}
|
||||
|
||||
Dialect dialect = dialectFactory.buildDialect(
|
||||
final Dialect dialect = dialectFactory.buildDialect(
|
||||
configurationValues,
|
||||
() -> {
|
||||
try {
|
||||
|
|
|
@ -319,6 +319,11 @@ public class HibernateSchemaManagementTool implements SchemaManagementTool, Serv
|
|||
public int getDriverMinorVersion() {
|
||||
return NO_VERSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLKeywords() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -96,4 +96,9 @@ public class TestingDialectResolutionInfo implements DialectResolutionInfo {
|
|||
public int getDriverMinorVersion() {
|
||||
return driverMinorVersion == NO_VERSION ? 0 : driverMinorVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLKeywords() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue