Class OracleDialect
- java.lang.Object
-
- org.hibernate.dialect.Dialect
-
- org.hibernate.dialect.OracleDialect
-
- All Implemented Interfaces:
ConversionContext
- Direct Known Subclasses:
Oracle10gDialect
,Oracle12cDialect
,Oracle8iDialect
,Oracle9iDialect
public class OracleDialect extends Dialect
A dialect for Oracle 8i and above.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.hibernate.dialect.Dialect
Dialect.SizeStrategy, Dialect.SizeStrategyImpl
-
-
Field Summary
Fields Modifier and Type Field Description static String
PREFER_LONG_RAW
-
Fields inherited from class org.hibernate.dialect.Dialect
CLOSED_QUOTE, LEGACY_LOB_MERGE_STRATEGY, NEW_LOCATOR_LOB_MERGE_STRATEGY, QUOTE, STANDARD_DEFAULT_BATCH_LOAD_SIZING_STRATEGY, STREAM_XFER_LOB_MERGE_STRATEGY
-
-
Constructor Summary
Constructors Constructor Description OracleDialect()
OracleDialect(DatabaseVersion version)
OracleDialect(DialectResolutionInfo info)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
appendBinaryLiteral(SqlAppender appender, byte[] bytes)
void
appendDatetimeFormat(SqlAppender appender, String format)
Translate the given datetime format string from the pattern language defined by Java'sDateTimeFormatter
to whatever pattern language is understood by the native datetime formatting function for this database (often theto_char()
function).SQLExceptionConversionDelegate
buildSQLExceptionConversionDelegate()
Build an instance of aSQLExceptionConversionDelegate
for interpreting dialect-specific error or SQLState codes.boolean
canCreateSchema()
Does this dialect support schema creation?String
castPattern(CastType from, CastType to)
Oracle doesn't have any sort ofTypes.BOOLEAN
type orTypes.TIME
type, and its default behavior for casting dates and timestamps to and from strings is just awful.protected String
columnType(int jdbcTypeCode)
void
contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry)
Allows the Dialect to contribute additional typesString
currentDate()
Translation of the HQL/JPQLcurrent_date
function, which maps to the Java typejava.sql.Date
, and of the HQLlocal_date
function which maps to the Java typejava.sql.LocalDate
.String
currentLocalTime()
Translation of the HQLlocal_time
function, which maps to the Java typejava.time.LocalTime
which is a time with no time zone.String
currentLocalTimestamp()
Translation of the HQLlocal_datetime
function, which maps to the Java typejava.time.LocalDateTime
which is a datetime with no time zone.String
currentTime()
Translation of the HQL/JPQLcurrent_time
function, which maps to the Java typejava.sql.Time
which is a time with no time zone.String
currentTimestamp()
Translation of the HQL/JPQLcurrent_timestamp
function, which maps to the Java typejava.sql.Timestamp
which is a datetime with no time zone.String
currentTimestampWithTimeZone()
Translation of the HQLoffset_datetime
function, which maps to the Java typejava.time.OffsetDateTime
which is a datetime with a time zone.static Replacer
datetimeFormat(String format, boolean useFm, boolean resetFm)
boolean
dropConstraints()
Do we need to drop constraints before dropping tables in this dialect?String
extractPattern(TemporalUnit unit)
Oracle supports a limited list of temporal fields in the extract() function, but we can emulate some of them by using to_char() with a format string instead of extract().boolean
forceLobAsLastValue()
HHH-4635 Oracle expects all Lob values to be last in inserts and updates.String
getAddColumnString()
The syntax used to add a column to a table (optional).CallableStatementSupport
getCallableStatementSupport()
String
getCascadeConstraintsString()
The keyword that specifies that adrop table
operation should be cascaded to its constraints, typically" cascade"
where the leading space is required, or the empty string if there is no such keyword in this dialect.String
getCurrentSchemaCommand()
Get the SQL command used to retrieve the current schema name.String
getCurrentTimestampSelectString()
Retrieve the command used to retrieve the current timestamp from the database.int
getDefaultStatementBatchSize()
The default value to use for the configuration propertyAvailableSettings.STATEMENT_BATCH_SIZE
.boolean
getDefaultUseGetGeneratedKeys()
The default value to use for the configuration propertyAvailableSettings.USE_GET_GENERATED_KEYS
.boolean
getDefaultUseStreamsForBinary()
The default value to use for the configuration propertyAvailableSettings.USE_STREAMS_FOR_BINARY
.SqmMultiTableInsertStrategy
getFallbackSqmInsertStrategy(EntityMappingType rootEntityDescriptor, RuntimeModelCreationContext runtimeModelCreationContext)
SqmMultiTableMutationStrategy
getFallbackSqmMutationStrategy(EntityMappingType rootEntityDescriptor, RuntimeModelCreationContext runtimeModelCreationContext)
String
getForUpdateNowaitString()
Retrieves the FOR UPDATE NOWAIT syntax specific to this dialect.String
getForUpdateNowaitString(String aliases)
Get the FOR UPDATE OF column_list NOWAIT fragment appropriate for this dialect given the aliases of the columns to be write locked.String
getForUpdateSkipLockedString()
Retrieves the FOR UPDATE SKIP LOCKED syntax specific to this dialect.String
getForUpdateSkipLockedString(String aliases)
Get the FOR UPDATE OF column_list SKIP LOCKED fragment appropriate for this dialect given the aliases of the columns to be write locked.String
getForUpdateString(String aliases)
Get the FOR UPDATE OF column_list fragment appropriate for this dialect given the aliases of the columns to be write locked.long
getFractionalSecondPrecisionInNanos()
We minimize multiplicative factors by using seconds (with fractional part) as the "native" precision for duration arithmetic.IdentityColumnSupport
getIdentityColumnSupport()
Get the appropriateIdentityColumnSupport
int
getInExpressionCountLimit()
Return the limit that the underlying database places on the number of elements in anIN
predicate.LimitHandler
getLimitHandler()
Returns aLimitHandler
that implements support forQuery.setMaxResults(int)
andQuery.setFirstResult(int)
for this dialect.int
getMaxAliasLength()
What is the maximum length Hibernate can use for generated aliases?int
getMaxIdentifierLength()
What is the maximum identifier length supported by the dialect?int
getMaxVarbinaryLength()
The longest possible length of aTypes.VARBINARY
-like column.int
getMaxVarcharLength()
The longest possible length of aTypes.VARCHAR
-like column.String
getNativeIdentifierGeneratorStrategy()
Resolves the native generation strategy associated to this dialect.int
getPreferredSqlTypeCodeForBoolean()
The JDBCtype code
to use for mapping properties of Java typeboolean
.String
getQueryHintString(String sql, String hints)
Apply a hint to the query.String
getQuerySequencesString()
Get the select command used retrieve the names of all sequences.String
getReadLockString(int timeout)
Get the string to append to SELECT statements to acquire READ locks for this dialect.String
getReadLockString(String aliases, int timeout)
Get the string to append to SELECT statements to acquire READ locks for this dialect given the aliases of the columns to be read locked.ResultSet
getResultSet(CallableStatement ps)
Given a callable statement previously processed byDialect.registerResultSetOutParameter(java.sql.CallableStatement, int)
, extract theResultSet
from the OUT parameter.ResultSet
getResultSet(CallableStatement statement, int position)
Given a callable statement previously processed byDialect.registerResultSetOutParameter(java.sql.CallableStatement, int)
, extract theResultSet
.ResultSet
getResultSet(CallableStatement statement, String name)
Given a callable statement previously processed byDialect.registerResultSetOutParameter(java.sql.CallableStatement, int)
, extract theResultSet
from the OUT parameter.String
getSelectClauseNullString(int sqlType)
Given aTypes
type code, determine an appropriate null value to use in a select clause.String
getSelectGUIDString()
Get the command used to select a GUID from the underlying database.SequenceInformationExtractor
getSequenceInformationExtractor()
A source ofSequenceInformation
.SequenceSupport
getSequenceSupport()
SqlAstTranslatorFactory
getSqlAstTranslatorFactory()
Return an SqlAstTranslatorFactory specific for the Dialect.protected List<Integer>
getSupportedJdbcTypeCodes()
TemporaryTableKind
getSupportedTemporaryTableKind()
String
getTemporaryTableCreateOptions()
TimeZoneSupport
getTimeZoneSupport()
How the Dialect supports time zone types likeTypes.TIMESTAMP_WITH_TIMEZONE
.ViolatedConstraintNameExtractor
getViolatedConstraintNameExtractor()
String
getWriteLockString(int timeout)
Get the string to append to SELECT statements to acquire WRITE locks for this dialect.String
getWriteLockString(String aliases, int timeout)
Get the string to append to SELECT statements to acquire WRITE locks for this dialect given the aliases of the columns to be write locked.RowLockStrategy
getWriteRowLockStrategy()
The row lock strategy to use for write locks.protected void
initDefaultProperties()
Set appropriate default values for configuration properties.void
initializeFunctionRegistry(QueryEngine queryEngine)
Initialize the given registry with any dialect-specific functions.boolean
isCurrentTimestampSelectStringCallable()
Should the value returned byDialect.getCurrentTimestampSelectString()
be treated as callable.boolean
isEmptyStringTreatedAsNull()
Return whether the dialect considers an empty-string value as null.int
registerResultSetOutParameter(CallableStatement statement, int col)
Registers a parameter (either OUT, or the new REF_CURSOR param type available in Java 8) capable of returningResultSet
*by position*.int
registerResultSetOutParameter(CallableStatement statement, String name)
Registers a parameter (either OUT, or the new REF_CURSOR param type available in Java 8) capable of returningResultSet
*by name*.JdbcType
resolveSqlTypeDescriptor(String columnTypeName, int jdbcTypeCode, int precision, int scale, JdbcTypeRegistry jdbcTypeRegistry)
boolean
supportsBitType()
Oracle has neitherBIT
norBOOLEAN
.boolean
supportsCommentOn()
Does this dialect/database support commenting on tables, columns, etc?boolean
supportsCurrentTimestampSelection()
Does this dialect support a way to retrieve the database's current timestamp value?boolean
supportsExistsInSelect()
Does the dialect support an exists statement in the select clause?boolean
supportsFetchClause(FetchClauseType type)
Does this dialect support the given fetch clause type.boolean
supportsLateral()
Does this dialect support the SQL lateral keyword or a proprietary alternative=boolean
supportsNoWait()
Does this dialect/database support NO_WAIT timeout.boolean
supportsOffsetInSubquery()
Does this dialect support offset in subqueries? Ex: select * from Table1 where col1 in (select col1 from Table2 order by col2 limit 1 offset 1)boolean
supportsPartitionBy()
Does the underlying database support partition byboolean
supportsSkipLocked()
Does this dialect/database support SKIP_LOCKED timeout.boolean
supportsTupleDistinctCounts()
Does this dialect support `count(distinct a,b)`?boolean
supportsWindowFunctions()
Does this dialect support window functions like `row_number() over (..)`String
timestampaddPattern(TemporalUnit unit, TemporalType temporalType, IntervalType intervalType)
Obtain a pattern for the SQL equivalent to atimestampadd()
function call.String
timestampdiffPattern(TemporalUnit unit, TemporalType fromTemporalType, TemporalType toTemporalType)
Obtain a pattern for the SQL equivalent to atimestampdiff()
function call.boolean
useFollowOnLocking(String sql, QueryOptions queryOptions)
For Oracle, the FOR UPDATE clause cannot be applied when using ORDER BY, DISTINCT or views.-
Methods inherited from class org.hibernate.dialect.Dialect
addSqlHintOrComment, appendBooleanValueString, appendDateTimeLiteral, appendDateTimeLiteral, appendDateTimeLiteral, appendIntervalLiteral, appendLiteral, appendLockHint, applyLocksToSql, augmentRecognizedTableTypes, beforeRegisteringColumnTypes, beforeRegisteringColumnTypes, binaryToDecimalPrecision, buildIdentifierHelper, canCreateCatalog, closeQuote, defaultScrollMode, doesReadCommittedCauseWritersToBlockReaders, doesRepeatableReadCauseReadersToBlockWriters, equivalentTypes, escapeComment, getAddColumnSuffixString, getAddForeignKeyConstraintString, getAddForeignKeyConstraintString, getAddPrimaryKeyConstraintString, getAlterTableString, getAuxiliaryDatabaseObjectExporter, getBooleanCheckCondition, getCaseInsensitiveLike, getCastTypeName, getColumnAliasExtractor, getColumnComment, getCreateCatalogCommand, getCreateMultisetTableString, getCreateSchemaCommand, getCreateTableString, getCreateTemporaryTableColumnAnnotation, getDefaultBatchLoadSizingStrategy, getDefaultDecimalPrecision, getDefaultLobLength, getDefaultNonContextualLobCreation, getDefaultProperties, getDefaultTimestampPrecision, getDoublePrecision, getDropCatalogCommand, getDropForeignKeyString, getDropSchemaCommand, getDropTableString, getEnumCheckCondition, getFloatPrecision, getForeignKeyExporter, getForUpdateString, getForUpdateString, getForUpdateString, getForUpdateString, getGroupBySelectItemReferenceStrategy, getHibernateTypeName, getHibernateTypeName, getHqlTranslator, getIndexExporter, getKeywords, getLobMergeStrategy, getLockingStrategy, getLockRowIdentifier, getLowercaseFunction, getMaxNVarcharLength, getNameQualifierSupport, getNationalizationSupport, getNoColumnsInsertString, getNullColumnString, getNullColumnString, getNullOrdering, getQueryHintString, getRawTypeName, getRawTypeName, getReadRowLockStrategy, getSchemaNameResolver, getSequenceExporter, getSizeStrategy, getSqmTranslatorFactory, getTableComment, getTableExporter, getTableTypeString, getTemporaryTableAfterUseAction, getTemporaryTableBeforeUseAction, getTemporaryTableCreateCommand, getTemporaryTableDdlTransactionHandling, getTemporaryTableDropCommand, getTemporaryTableExporter, getTemporaryTableTruncateCommand, getTypeName, getTypeName, getTypeName, getTypeName, getUniqueDelegate, getUniqueKeyExporter, getVersion, hasAlterTable, hasSelfReferentialForeignKeyBug, inlineLiteral, isAnsiNullOn, isJdbcLogWarningsEnabledByDefault, isLockTimeoutParameterized, isTypeNameRegistered, openQuote, prependComment, qualifyIndexName, quote, registerColumnType, registerColumnType, registerDefaultColumnTypes, registerDefaultColumnTypes, registerDefaultKeywords, registerHibernateType, registerHibernateType, registerHibernateTypes, registerKeyword, registerKeywords, requiresFloatCastingOfIntegerDivision, requiresParensForTupleCounts, requiresParensForTupleDistinctCounts, resolveSqlTypeLength, supportsBindAsCallableArgument, supportsCascadeDelete, supportsCaseInsensitiveLike, supportsCircularCascadeDeleteConstraints, supportsColumnCheck, supportsExpectedLobUsagePattern, supportsFractionalTimestampArithmetic, supportsIfExistsAfterAlterTable, supportsIfExistsAfterConstraintName, supportsIfExistsAfterTableName, supportsIfExistsBeforeConstraintName, supportsIfExistsBeforeTableName, supportsJdbcConnectionLobCreation, supportsLobValueChangePropagation, supportsLockTimeouts, supportsNamedParameters, supportsNoColumnsInsert, supportsNonQueryWithCTE, supportsNullPrecedence, supportsOrderByInSubquery, supportsOrdinalSelectItemReference, supportsOuterJoinForUpdate, supportsParametersInInsertSelect, supportsResultSetPositionQueryMethodsOnForwardOnlyCursor, supportsSubqueryInSelect, supportsSubqueryOnMutatingTable, supportsSubselectAsInPredicateLHS, supportsTableCheck, supportsTemporalLiteralOffset, supportsTemporaryTablePrimaryKey, supportsTemporaryTables, supportsTruncateWithCast, supportsTupleCounts, supportsUnboundedLobLocatorMaterialization, supportsUnionAll, supportsUnionInSubquery, supportsValuesList, supportsValuesListForInsert, supportsWait, toBooleanValueString, toString, transformSelectString, translateDurationField, translateExtractField, trimPattern, useInputStreamToInsertBlob
-
-
-
-
Field Detail
-
PREFER_LONG_RAW
public static final String PREFER_LONG_RAW
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
OracleDialect
public OracleDialect()
-
OracleDialect
public OracleDialect(DatabaseVersion version)
-
OracleDialect
public OracleDialect(DialectResolutionInfo info)
-
-
Method Detail
-
getPreferredSqlTypeCodeForBoolean
public int getPreferredSqlTypeCodeForBoolean()
Description copied from class:Dialect
The JDBCtype code
to use for mapping properties of Java typeboolean
.Usually
Types.BOOLEAN
orTypes.BIT
.- Overrides:
getPreferredSqlTypeCodeForBoolean
in classDialect
- Returns:
- one of the type codes defined by
Types
.
-
initializeFunctionRegistry
public void initializeFunctionRegistry(QueryEngine queryEngine)
Description copied from class:Dialect
Initialize the given registry with any dialect-specific functions. Support for certain SQL functions is required, and if the database does not support a required function, then the dialect must define a way to emulate it. These required functions include the functions defined by the JPA query language specification:- avg(arg) - aggregate function
- count([distinct ]arg) - aggregate function
- max(arg) - aggregate function
- min(arg) - aggregate function
- sum(arg) - aggregate function
- coalesce(arg0, arg1, ...)
- nullif(arg0, arg1)
- lower(arg)
- upper(arg)
- length(arg)
- concat(arg0, arg1, ...)
- locate(pattern, string[, start])
- substring(string, start[, length])
- trim([[spec ][character ]from] string)
- abs(arg)
- mod(arg0, arg1)
- sqrt(arg)
- current date
- current time
- current timestamp
- any(arg) - aggregate function
- every(arg) - aggregate function
- cast(arg as Type)
- extract(field from arg)
- ln(arg)
- exp(arg)
- power(arg0, arg1)
- floor(arg)
- ceiling(arg)
- position(pattern in string)
- substring(string from start[ for length])
- overlay(string placing replacement from start[ for length])
- local date
- local time
- local datetime
- offset datetime
- instant
- left(string, length)
- right(string, length)
- replace(string, pattern, replacement)
- pad(string with length spec[ character])
- sign(arg)
- sin(arg)
- cos(arg)
- tan(arg)
- asin(arg)
- acos(arg)
- atan(arg)
- atan2(arg0, arg1)
- round(arg0, arg1)
- least(arg0, arg1, ...)
- greatest(arg0, arg1, ...)
- format(datetime as pattern)
- str(arg) - synonym of cast(a as String)
- ifnull(arg0, arg1) - synonym of coalesce(a, b)
- second(arg) - synonym of extract(second from a)
- minute(arg) - synonym of extract(minute from a)
- hour(arg) - synonym of extract(hour from a)
- day(arg) - synonym of extract(day from a)
- month(arg) - synonym of extract(month from a)
- year(arg) - synonym of extract(year from a)
- Overrides:
initializeFunctionRegistry
in classDialect
-
getMaxVarcharLength
public int getMaxVarcharLength()
Description copied from class:Dialect
The longest possible length of aTypes.VARCHAR
-like column. For longer column lengths, use some sort oftext
-like type for the column.- Overrides:
getMaxVarcharLength
in classDialect
-
getMaxVarbinaryLength
public int getMaxVarbinaryLength()
Description copied from class:Dialect
The longest possible length of aTypes.VARBINARY
-like column. For longer column lengths, use some sort ofimage
-like type for the column.- Overrides:
getMaxVarbinaryLength
in classDialect
-
getSqlAstTranslatorFactory
public SqlAstTranslatorFactory getSqlAstTranslatorFactory()
Description copied from class:Dialect
Return an SqlAstTranslatorFactory specific for the Dialect. Returnnull
to use Hibernate's standard translator.- Overrides:
getSqlAstTranslatorFactory
in classDialect
- See Also:
StandardSqlAstTranslatorFactory
,JdbcEnvironment.getSqlAstTranslatorFactory()
-
currentDate
public String currentDate()
Description copied from class:Dialect
Translation of the HQL/JPQLcurrent_date
function, which maps to the Java typejava.sql.Date
, and of the HQLlocal_date
function which maps to the Java typejava.sql.LocalDate
.- Overrides:
currentDate
in classDialect
-
currentTime
public String currentTime()
Description copied from class:Dialect
Translation of the HQL/JPQLcurrent_time
function, which maps to the Java typejava.sql.Time
which is a time with no time zone. This contradicts ANSI SQL wherecurrent_time
has the typeTIME WITH TIME ZONE
.It is recommended to override this in dialects for databases which support
localtime
ortime at local
.- Overrides:
currentTime
in classDialect
-
currentTimestamp
public String currentTimestamp()
Description copied from class:Dialect
Translation of the HQL/JPQLcurrent_timestamp
function, which maps to the Java typejava.sql.Timestamp
which is a datetime with no time zone. This contradicts ANSI SQL wherecurrent_timestamp
has the typeTIMESTAMP WITH TIME ZONE
.It is recommended to override this in dialects for databases which support
localtimestamp
ortimestamp at local
.- Overrides:
currentTimestamp
in classDialect
-
currentLocalTime
public String currentLocalTime()
Description copied from class:Dialect
Translation of the HQLlocal_time
function, which maps to the Java typejava.time.LocalTime
which is a time with no time zone. It should usually be the same SQL function as forDialect.currentTime()
.It is recommended to override this in dialects for databases which support
localtime
orcurrent_time at local
.- Overrides:
currentLocalTime
in classDialect
-
currentLocalTimestamp
public String currentLocalTimestamp()
Description copied from class:Dialect
Translation of the HQLlocal_datetime
function, which maps to the Java typejava.time.LocalDateTime
which is a datetime with no time zone. It should usually be the same SQL function as forDialect.currentTimestamp()
.It is recommended to override this in dialects for databases which support
localtimestamp
orcurrent_timestamp at local
.- Overrides:
currentLocalTimestamp
in classDialect
-
currentTimestampWithTimeZone
public String currentTimestampWithTimeZone()
Description copied from class:Dialect
Translation of the HQLoffset_datetime
function, which maps to the Java typejava.time.OffsetDateTime
which is a datetime with a time zone. This in principle correctly maps to the ANSI SQLcurrent_timestamp
which has the typeTIMESTAMP WITH TIME ZONE
.- Overrides:
currentTimestampWithTimeZone
in classDialect
-
castPattern
public String castPattern(CastType from, CastType to)
Oracle doesn't have any sort ofTypes.BOOLEAN
type orTypes.TIME
type, and its default behavior for casting dates and timestamps to and from strings is just awful.- Overrides:
castPattern
in classDialect
- Parameters:
from
- aCastType
indicating the type of the value argumentto
- aCastType
indicating the type the value argument is cast to
-
getFractionalSecondPrecisionInNanos
public long getFractionalSecondPrecisionInNanos()
We minimize multiplicative factors by using seconds (with fractional part) as the "native" precision for duration arithmetic.- Overrides:
getFractionalSecondPrecisionInNanos
in classDialect
- Returns:
- the precision, specified as a quantity of nanoseconds
- See Also:
TemporalUnit.NATIVE
-
extractPattern
public String extractPattern(TemporalUnit unit)
Oracle supports a limited list of temporal fields in the extract() function, but we can emulate some of them by using to_char() with a format string instead of extract(). Thus, the additional supported fields areTemporalUnit.DAY_OF_YEAR
,TemporalUnit.DAY_OF_MONTH
,TemporalUnit.DAY_OF_YEAR
, andTemporalUnit.WEEK
.- Overrides:
extractPattern
in classDialect
- Parameters:
unit
- the first argument
-
timestampaddPattern
public String timestampaddPattern(TemporalUnit unit, TemporalType temporalType, IntervalType intervalType)
Description copied from class:Dialect
Obtain a pattern for the SQL equivalent to atimestampadd()
function call. The resulting pattern must contain ?1, ?2, and ?3 placeholders for the arguments.- Overrides:
timestampaddPattern
in classDialect
- Parameters:
unit
- The unit to add to the temporaltemporalType
- The type of the temporalintervalType
- The type of interval to add or null if it's not a native interval
-
timestampdiffPattern
public String timestampdiffPattern(TemporalUnit unit, TemporalType fromTemporalType, TemporalType toTemporalType)
Description copied from class:Dialect
Obtain a pattern for the SQL equivalent to atimestampdiff()
function call. The resulting pattern must contain ?1, ?2, and ?3 placeholders for the arguments.- Overrides:
timestampdiffPattern
in classDialect
- Parameters:
unit
- the first argumentfromTemporalType
- true if the first argument is a timestamp, false if a datetoTemporalType
- true if the second argument is
-
columnType
protected String columnType(int jdbcTypeCode)
Description copied from class:Dialect
The column type name for a given JDBC type code defined inTypes
orSqlTypes
. This default implementation returns the ANSI-standard type name.This method may be overridden by concrete
Dialect
s as an alternative to callingDialect.registerColumnType(int,String)
.- Overrides:
columnType
in classDialect
- Parameters:
jdbcTypeCode
- a JDBC type code- Returns:
- a column type name, with $l, $p, $s placeholders for length, precision, scale
- See Also:
SqlTypes
,Dialect.getSupportedJdbcTypeCodes()
-
getSupportedJdbcTypeCodes
protected List<Integer> getSupportedJdbcTypeCodes()
Description copied from class:Dialect
The JDBC type codes of types supported by this SQL dialect, from the lists defined byTypes
andSqlTypes
.This method may be overridden by concrete
Dialect
s as an alternative to callingDialect.registerColumnType(int, String)
. In this case,Dialect.columnType(int)
should also be overridden.Note that
Types.LONGVARCHAR
,Types.LONGNVARCHAR
andTypes.LONGVARBINARY
are considered synonyms for their non-LONG
counterparts, and should not be included in the returned array.- Overrides:
getSupportedJdbcTypeCodes
in classDialect
- Returns:
- an array of types from
SqlTypes
- See Also:
SqlTypes
,Dialect.columnType(int)
-
getTimeZoneSupport
public TimeZoneSupport getTimeZoneSupport()
Description copied from class:Dialect
How the Dialect supports time zone types likeTypes.TIMESTAMP_WITH_TIMEZONE
.- Overrides:
getTimeZoneSupport
in classDialect
-
initDefaultProperties
protected void initDefaultProperties()
Description copied from class:Dialect
Set appropriate default values for configuration properties.- Overrides:
initDefaultProperties
in classDialect
-
getDefaultStatementBatchSize
public int getDefaultStatementBatchSize()
Description copied from class:Dialect
The default value to use for the configuration propertyAvailableSettings.STATEMENT_BATCH_SIZE
.- Overrides:
getDefaultStatementBatchSize
in classDialect
-
getDefaultUseStreamsForBinary
public boolean getDefaultUseStreamsForBinary()
Description copied from class:Dialect
The default value to use for the configuration propertyAvailableSettings.USE_STREAMS_FOR_BINARY
.- Overrides:
getDefaultUseStreamsForBinary
in classDialect
-
getDefaultUseGetGeneratedKeys
public boolean getDefaultUseGetGeneratedKeys()
Description copied from class:Dialect
The default value to use for the configuration propertyAvailableSettings.USE_GET_GENERATED_KEYS
.- Overrides:
getDefaultUseGetGeneratedKeys
in classDialect
-
resolveSqlTypeDescriptor
public JdbcType resolveSqlTypeDescriptor(String columnTypeName, int jdbcTypeCode, int precision, int scale, JdbcTypeRegistry jdbcTypeRegistry)
- Overrides:
resolveSqlTypeDescriptor
in classDialect
-
supportsBitType
public boolean supportsBitType()
Oracle has neitherBIT
norBOOLEAN
.- Overrides:
supportsBitType
in classDialect
- Returns:
- false
-
contributeTypes
public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry)
Description copied from class:Dialect
Allows the Dialect to contribute additional types- Overrides:
contributeTypes
in classDialect
- Parameters:
typeContributions
- Callback to contribute the typesserviceRegistry
- The service registry
-
getNativeIdentifierGeneratorStrategy
public String getNativeIdentifierGeneratorStrategy()
Description copied from class:Dialect
Resolves the native generation strategy associated to this dialect. Comes into play whenever the user specifies the native generator.- Overrides:
getNativeIdentifierGeneratorStrategy
in classDialect
- Returns:
- The native generator strategy.
-
getIdentityColumnSupport
public IdentityColumnSupport getIdentityColumnSupport()
Description copied from class:Dialect
Get the appropriateIdentityColumnSupport
- Overrides:
getIdentityColumnSupport
in classDialect
- Returns:
- the IdentityColumnSupport
-
getLimitHandler
public LimitHandler getLimitHandler()
Description copied from class:Dialect
Returns aLimitHandler
that implements support forQuery.setMaxResults(int)
andQuery.setFirstResult(int)
for this dialect.- Overrides:
getLimitHandler
in classDialect
-
getSelectClauseNullString
public String getSelectClauseNullString(int sqlType)
Description copied from class:Dialect
Given aTypes
type code, determine an appropriate null value to use in a select clause. One thing to consider here is that certain databases might require proper casting for the nulls here since the select here will be part of a UNION/UNION ALL.- Overrides:
getSelectClauseNullString
in classDialect
- Parameters:
sqlType
- TheTypes
type code.- Returns:
- The appropriate select clause value fragment.
-
getCurrentTimestampSelectString
public String getCurrentTimestampSelectString()
Description copied from class:Dialect
Retrieve the command used to retrieve the current timestamp from the database.- Overrides:
getCurrentTimestampSelectString
in classDialect
- Returns:
- The command.
-
getAddColumnString
public String getAddColumnString()
Description copied from class:Dialect
The syntax used to add a column to a table (optional).- Overrides:
getAddColumnString
in classDialect
- Returns:
- The "add column" fragment.
-
getCascadeConstraintsString
public String getCascadeConstraintsString()
Description copied from class:Dialect
The keyword that specifies that adrop table
operation should be cascaded to its constraints, typically" cascade"
where the leading space is required, or the empty string if there is no such keyword in this dialect.- Overrides:
getCascadeConstraintsString
in classDialect
- Returns:
- The cascade drop keyword, if any, with a leading space
-
dropConstraints
public boolean dropConstraints()
Description copied from class:Dialect
Do we need to drop constraints before dropping tables in this dialect?- Overrides:
dropConstraints
in classDialect
- Returns:
- True if constraints must be dropped prior to dropping the table; false otherwise.
-
getSequenceSupport
public SequenceSupport getSequenceSupport()
- Overrides:
getSequenceSupport
in classDialect
-
getQuerySequencesString
public String getQuerySequencesString()
Description copied from class:Dialect
Get the select command used retrieve the names of all sequences.- Overrides:
getQuerySequencesString
in classDialect
- Returns:
- The select command; or null if sequences are not supported.
-
getSequenceInformationExtractor
public SequenceInformationExtractor getSequenceInformationExtractor()
Description copied from class:Dialect
A source ofSequenceInformation
.- Overrides:
getSequenceInformationExtractor
in classDialect
-
getSelectGUIDString
public String getSelectGUIDString()
Description copied from class:Dialect
Get the command used to select a GUID from the underlying database. Optional operation.- Overrides:
getSelectGUIDString
in classDialect
- Returns:
- The appropriate command.
-
getViolatedConstraintNameExtractor
public ViolatedConstraintNameExtractor getViolatedConstraintNameExtractor()
- Specified by:
getViolatedConstraintNameExtractor
in interfaceConversionContext
- Overrides:
getViolatedConstraintNameExtractor
in classDialect
-
buildSQLExceptionConversionDelegate
public SQLExceptionConversionDelegate buildSQLExceptionConversionDelegate()
Description copied from class:Dialect
Build an instance of aSQLExceptionConversionDelegate
for interpreting dialect-specific error or SQLState codes. If this method is overridden to return a non-null value, the defaultSQLExceptionConverter
will use the returnedSQLExceptionConversionDelegate
in addition to the following standard delegates:- a "static" delegate based on the JDBC 4 defined SQLException hierarchy;
- a delegate that interprets SQLState codes for either X/Open or SQL-2003 codes, depending on java.sql.DatabaseMetaData#getSQLStateType
- Overrides:
buildSQLExceptionConversionDelegate
in classDialect
- Returns:
- The SQLExceptionConversionDelegate for this dialect
-
registerResultSetOutParameter
public int registerResultSetOutParameter(CallableStatement statement, int col) throws SQLException
Description copied from class:Dialect
Registers a parameter (either OUT, or the new REF_CURSOR param type available in Java 8) capable of returningResultSet
*by position*. Pre-Java 8, registering such ResultSet-returning parameters varied greatly across database and drivers; hence its inclusion as part of the Dialect contract.- Overrides:
registerResultSetOutParameter
in classDialect
- Parameters:
statement
- The callable statement.col
- The bind position at which to register the output param.- Returns:
- The number of (contiguous) bind positions used.
- Throws:
SQLException
- Indicates problems registering the param.
-
getResultSet
public ResultSet getResultSet(CallableStatement ps) throws SQLException
Description copied from class:Dialect
Given a callable statement previously processed byDialect.registerResultSetOutParameter(java.sql.CallableStatement, int)
, extract theResultSet
from the OUT parameter.- Overrides:
getResultSet
in classDialect
- Parameters:
ps
- The callable statement.- Returns:
- The extracted result set.
- Throws:
SQLException
- Indicates problems extracting the result set.
-
supportsCommentOn
public boolean supportsCommentOn()
Description copied from class:Dialect
Does this dialect/database support commenting on tables, columns, etc?- Overrides:
supportsCommentOn
in classDialect
- Returns:
true
if commenting is supported
-
supportsCurrentTimestampSelection
public boolean supportsCurrentTimestampSelection()
Description copied from class:Dialect
Does this dialect support a way to retrieve the database's current timestamp value?- Overrides:
supportsCurrentTimestampSelection
in classDialect
- Returns:
- True if the current timestamp can be retrieved; false otherwise.
-
isCurrentTimestampSelectStringCallable
public boolean isCurrentTimestampSelectStringCallable()
Description copied from class:Dialect
Should the value returned byDialect.getCurrentTimestampSelectString()
be treated as callable. Typically this indicates that JDBC escape syntax is being used...- Overrides:
isCurrentTimestampSelectStringCallable
in classDialect
- Returns:
- True if the
Dialect.getCurrentTimestampSelectString()
return is callable; false otherwise.
-
supportsExistsInSelect
public boolean supportsExistsInSelect()
Description copied from class:Dialect
Does the dialect support an exists statement in the select clause?- Overrides:
supportsExistsInSelect
in classDialect
- Returns:
- True if exists checks are allowed in the select clause; false otherwise.
-
getInExpressionCountLimit
public int getInExpressionCountLimit()
Description copied from class:Dialect
Return the limit that the underlying database places on the number of elements in anIN
predicate. If the database defines no such limits, simply return zero or less-than-zero.- Overrides:
getInExpressionCountLimit
in classDialect
- Returns:
- int The limit, or zero-or-less to indicate no limit.
-
forceLobAsLastValue
public boolean forceLobAsLastValue()
Description copied from class:Dialect
HHH-4635 Oracle expects all Lob values to be last in inserts and updates.- Overrides:
forceLobAsLastValue
in classDialect
- Returns:
- boolean True if Lob values should be last, false if it does not matter.
-
isEmptyStringTreatedAsNull
public boolean isEmptyStringTreatedAsNull()
Description copied from class:Dialect
Return whether the dialect considers an empty-string value as null.- Overrides:
isEmptyStringTreatedAsNull
in classDialect
- Returns:
- boolean True if an empty string is treated as null, false otherwise.
-
getFallbackSqmMutationStrategy
public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy(EntityMappingType rootEntityDescriptor, RuntimeModelCreationContext runtimeModelCreationContext)
- Overrides:
getFallbackSqmMutationStrategy
in classDialect
-
getFallbackSqmInsertStrategy
public SqmMultiTableInsertStrategy getFallbackSqmInsertStrategy(EntityMappingType rootEntityDescriptor, RuntimeModelCreationContext runtimeModelCreationContext)
- Overrides:
getFallbackSqmInsertStrategy
in classDialect
-
getSupportedTemporaryTableKind
public TemporaryTableKind getSupportedTemporaryTableKind()
- Overrides:
getSupportedTemporaryTableKind
in classDialect
-
getTemporaryTableCreateOptions
public String getTemporaryTableCreateOptions()
- Overrides:
getTemporaryTableCreateOptions
in classDialect
-
useFollowOnLocking
public boolean useFollowOnLocking(String sql, QueryOptions queryOptions)
For Oracle, the FOR UPDATE clause cannot be applied when using ORDER BY, DISTINCT or views.- Overrides:
useFollowOnLocking
in classDialect
- Returns:
true
indicates that the dialect requests that locking be applied by subsequent select;false
(the default) indicates that locking should be applied to the main SQL statement..- See Also:
- Oracle FOR UPDATE restrictions
-
getQueryHintString
public String getQueryHintString(String sql, String hints)
Description copied from class:Dialect
Apply a hint to the query. The entire query is provided, allowing the Dialect full control over the placement and syntax of the hint. By default, ignore the hint and simply return the query.- Overrides:
getQueryHintString
in classDialect
- Parameters:
sql
- The query to which to apply the hint.hints
- The hints to apply- Returns:
- The modified SQL
-
getMaxAliasLength
public int getMaxAliasLength()
Description copied from class:Dialect
What is the maximum length Hibernate can use for generated aliases? The maximum here should account for the fact that Hibernate often needs to append "uniqueing" information to the end of generated aliases. That "uniqueing" information will be added to the end of a identifier generated to the length specified here; so be sure to leave some room (generally speaking 5 positions will suffice).- Overrides:
getMaxAliasLength
in classDialect
- Returns:
- The maximum length.
-
getMaxIdentifierLength
public int getMaxIdentifierLength()
Description copied from class:Dialect
What is the maximum identifier length supported by the dialect?- Overrides:
getMaxIdentifierLength
in classDialect
- Returns:
- The maximum length.
-
getCallableStatementSupport
public CallableStatementSupport getCallableStatementSupport()
- Overrides:
getCallableStatementSupport
in classDialect
-
canCreateSchema
public boolean canCreateSchema()
Description copied from class:Dialect
Does this dialect support schema creation?- Overrides:
canCreateSchema
in classDialect
- Returns:
- True if the dialect supports schema creation; false otherwise.
-
getCurrentSchemaCommand
public String getCurrentSchemaCommand()
Description copied from class:Dialect
Get the SQL command used to retrieve the current schema name. Works in conjunction withDialect.getSchemaNameResolver()
, unless the return from there does not need this information. E.g., a custom impl might make use of the Java 1.7 addition of theConnection.getSchema()
method- Overrides:
getCurrentSchemaCommand
in classDialect
- Returns:
- The current schema retrieval SQL
-
supportsPartitionBy
public boolean supportsPartitionBy()
Description copied from class:Dialect
Does the underlying database support partition by- Overrides:
supportsPartitionBy
in classDialect
- Returns:
- boolean
-
supportsTupleDistinctCounts
public boolean supportsTupleDistinctCounts()
Description copied from class:Dialect
Does this dialect support `count(distinct a,b)`?- Overrides:
supportsTupleDistinctCounts
in classDialect
- Returns:
- True if the database supports counting distinct tuples; false otherwise.
-
supportsOffsetInSubquery
public boolean supportsOffsetInSubquery()
Description copied from class:Dialect
Does this dialect support offset in subqueries? Ex: select * from Table1 where col1 in (select col1 from Table2 order by col2 limit 1 offset 1)- Overrides:
supportsOffsetInSubquery
in classDialect
- Returns:
- boolean
-
supportsFetchClause
public boolean supportsFetchClause(FetchClauseType type)
Description copied from class:Dialect
Does this dialect support the given fetch clause type.- Overrides:
supportsFetchClause
in classDialect
- Parameters:
type
- The fetch clause type- Returns:
true
if the underlying database supports the given fetch clause type,false
otherwise. The default isfalse
.
-
supportsWindowFunctions
public boolean supportsWindowFunctions()
Description copied from class:Dialect
Does this dialect support window functions like `row_number() over (..)`- Overrides:
supportsWindowFunctions
in classDialect
- Returns:
true
if the underlying database supports window functions,false
otherwise. The default isfalse
.
-
supportsLateral
public boolean supportsLateral()
Description copied from class:Dialect
Does this dialect support the SQL lateral keyword or a proprietary alternative=- Overrides:
supportsLateral
in classDialect
- Returns:
true
if the underlying database supports lateral,false
otherwise. The default isfalse
.
-
supportsNoWait
public boolean supportsNoWait()
Description copied from class:Dialect
Does this dialect/database support NO_WAIT timeout.- Overrides:
supportsNoWait
in classDialect
- Returns:
true
if NO_WAIT is supported
-
supportsSkipLocked
public boolean supportsSkipLocked()
Description copied from class:Dialect
Does this dialect/database support SKIP_LOCKED timeout.- Overrides:
supportsSkipLocked
in classDialect
- Returns:
true
if SKIP_LOCKED is supported
-
getWriteRowLockStrategy
public RowLockStrategy getWriteRowLockStrategy()
Description copied from class:Dialect
The row lock strategy to use for write locks.- Overrides:
getWriteRowLockStrategy
in classDialect
-
getForUpdateNowaitString
public String getForUpdateNowaitString()
Description copied from class:Dialect
Retrieves the FOR UPDATE NOWAIT syntax specific to this dialect.- Overrides:
getForUpdateNowaitString
in classDialect
- Returns:
- The appropriate FOR UPDATE NOWAIT clause string.
-
getForUpdateString
public String getForUpdateString(String aliases)
Description copied from class:Dialect
Get the FOR UPDATE OF column_list fragment appropriate for this dialect given the aliases of the columns to be write locked.- Overrides:
getForUpdateString
in classDialect
- Parameters:
aliases
- The columns to be write locked.- Returns:
- The appropriate FOR UPDATE OF column_list clause string.
-
getForUpdateNowaitString
public String getForUpdateNowaitString(String aliases)
Description copied from class:Dialect
Get the FOR UPDATE OF column_list NOWAIT fragment appropriate for this dialect given the aliases of the columns to be write locked.- Overrides:
getForUpdateNowaitString
in classDialect
- Parameters:
aliases
- The columns to be write locked.- Returns:
- The appropriate FOR UPDATE OF colunm_list NOWAIT clause string.
-
getForUpdateSkipLockedString
public String getForUpdateSkipLockedString()
Description copied from class:Dialect
Retrieves the FOR UPDATE SKIP LOCKED syntax specific to this dialect.- Overrides:
getForUpdateSkipLockedString
in classDialect
- Returns:
- The appropriate FOR UPDATE SKIP LOCKED clause string.
-
getForUpdateSkipLockedString
public String getForUpdateSkipLockedString(String aliases)
Description copied from class:Dialect
Get the FOR UPDATE OF column_list SKIP LOCKED fragment appropriate for this dialect given the aliases of the columns to be write locked.- Overrides:
getForUpdateSkipLockedString
in classDialect
- Parameters:
aliases
- The columns to be write locked.- Returns:
- The appropriate FOR UPDATE colunm_list SKIP LOCKED clause string.
-
getWriteLockString
public String getWriteLockString(int timeout)
Description copied from class:Dialect
Get the string to append to SELECT statements to acquire WRITE locks for this dialect. Location of the returned string is treated the same as getForUpdateString.- Overrides:
getWriteLockString
in classDialect
- Parameters:
timeout
- in milliseconds, -1 for indefinite wait and 0 for no wait.- Returns:
- The appropriate LOCK clause string.
-
getWriteLockString
public String getWriteLockString(String aliases, int timeout)
Description copied from class:Dialect
Get the string to append to SELECT statements to acquire WRITE locks for this dialect given the aliases of the columns to be write locked. Location of the of the returned string is treated the same as getForUpdateString.- Overrides:
getWriteLockString
in classDialect
- Parameters:
aliases
- The columns to be read locked.timeout
- in milliseconds, -1 for indefinite wait and 0 for no wait.- Returns:
- The appropriate LOCK clause string.
-
getReadLockString
public String getReadLockString(int timeout)
Description copied from class:Dialect
Get the string to append to SELECT statements to acquire READ locks for this dialect. Location of the returned string is treated the same as getForUpdateString.- Overrides:
getReadLockString
in classDialect
- Parameters:
timeout
- in milliseconds, -1 for indefinite wait and 0 for no wait.- Returns:
- The appropriate LOCK clause string.
-
getReadLockString
public String getReadLockString(String aliases, int timeout)
Description copied from class:Dialect
Get the string to append to SELECT statements to acquire READ locks for this dialect given the aliases of the columns to be read locked. Location of the returned string is treated the same as getForUpdateString.- Overrides:
getReadLockString
in classDialect
- Parameters:
aliases
- The columns to be read locked.timeout
- in milliseconds, -1 for indefinite wait and 0 for no wait.- Returns:
- The appropriate LOCK clause string.
-
appendDatetimeFormat
public void appendDatetimeFormat(SqlAppender appender, String format)
Description copied from class:Dialect
Translate the given datetime format string from the pattern language defined by Java'sDateTimeFormatter
to whatever pattern language is understood by the native datetime formatting function for this database (often theto_char()
function).Since it's never possible to translate all of the pattern letter sequences understood by
DateTimeFormatter
, only the following subset of pattern letters is accepted by Hibernate:- G: era
- y: year of era
- Y: year of week-based year
- M: month of year
- w: week of week-based year (ISO week number)
- W: week of month
- E: day of week (name)
- e: day of week (number)
- d: day of month
- D: day of year
- a: AM/PM
- H: hour of day (24 hour time)
- h: hour of AM/PM (12 hour time)
- m: minutes
- s: seconds
- z,Z,x: timezone offset
- Overrides:
appendDatetimeFormat
in classDialect
-
datetimeFormat
public static Replacer datetimeFormat(String format, boolean useFm, boolean resetFm)
-
appendBinaryLiteral
public void appendBinaryLiteral(SqlAppender appender, byte[] bytes)
- Overrides:
appendBinaryLiteral
in classDialect
-
getResultSet
public ResultSet getResultSet(CallableStatement statement, int position) throws SQLException
Description copied from class:Dialect
Given a callable statement previously processed byDialect.registerResultSetOutParameter(java.sql.CallableStatement, int)
, extract theResultSet
.- Overrides:
getResultSet
in classDialect
- Parameters:
statement
- The callable statement.position
- The bind position at which to register the output param.- Returns:
- The extracted result set.
- Throws:
SQLException
- Indicates problems extracting the result set.
-
registerResultSetOutParameter
public int registerResultSetOutParameter(CallableStatement statement, String name) throws SQLException
Description copied from class:Dialect
Registers a parameter (either OUT, or the new REF_CURSOR param type available in Java 8) capable of returningResultSet
*by name*. Pre-Java 8, registering such ResultSet-returning parameters varied greatly across database and drivers; hence its inclusion as part of the Dialect contract.- Overrides:
registerResultSetOutParameter
in classDialect
- Parameters:
statement
- The callable statement.name
- The parameter name (for drivers which support named parameters).- Returns:
- The number of (contiguous) bind positions used.
- Throws:
SQLException
- Indicates problems registering the param.
-
getResultSet
public ResultSet getResultSet(CallableStatement statement, String name) throws SQLException
Description copied from class:Dialect
Given a callable statement previously processed byDialect.registerResultSetOutParameter(java.sql.CallableStatement, int)
, extract theResultSet
from the OUT parameter.- Overrides:
getResultSet
in classDialect
- Parameters:
statement
- The callable statement.name
- The parameter name (for drivers which support named parameters).- Returns:
- The extracted result set.
- Throws:
SQLException
- Indicates problems extracting the result set.
-
-