-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumBehavior used when ending a query only transaction (at read committed isolation level). -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanWhen set to true all db column names and table names use quoted identifiers.protected BasicSqlLimiterLimit/offset support for SqlQuery only.protected intThe JDBC type to map Blob to.protected intThe JDBC type to map booleans to (by default).protected booleanprotected intThe JDBC type to map Clob to.protected StringThe close quote used by quoted identifiers.protected Stringprotected DbDefaultValueDefault values for DB columns.protected DbEncryptprotected DbIdentityDefines DB identity/sequence features.protected DbPlatformTypeMappingMapping of JDBC to Database types.protected SqlExceptionTranslatorprotected booleanIf set then use the FORWARD ONLY hint when creating ResultSets for findIterate() and findVisit().protected DbHistorySupportThe history support for this database platform.protected booleanprotected booleanSet true if the Database support LIMIT clause on sql update.protected StringEscaped like clause for startsWith, endsWith and contains.protected StringThe non-escaped like clause (to stop slash being escaped on some platforms).protected charEscape character used for startsWith, endsWith and contains.protected char[]Characters escaped for startsWith, endsWith and contains.protected intA value of 60 is a reasonable default for all databases except Oracle (limited to 30) and DB2 (limited to 18).protected intprotected intThe maximum length of table names - used specifically when derived default table names for intersection tables.protected booleanSet to true if the DB has native UUID type support.protected DatabasePlatform.OnQueryOnlyThe behaviour used when ending a read only transaction at read committed isolation level.protected StringThe open quote used by quoted identifiers.protected io.ebean.annotation.PersistBatchBy default we use JDBC batch when cascading (except for SQL Server and HANA).protected io.ebean.annotation.PlatformThe database platform name.protected booleanprotected booleanprotected booleanprotected intprotected SqlLimiterFor limit/offset, row_number etc limiting of SQL queries.protected booleanprotected booleanprotected booleanCan we use native java time API objects inResultSet.getObject(int, Class)andPreparedStatement.setObject(int, Object).protected booleanIf set then use the CONCUR_UPDATABLE hint when creating ResultSets.protected booleanprotected booleanFor Oracle treat empty strings as null.protected Stringprotected booleanSet to true for MySql, no other jdbc drivers need this workaround.protected boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddGeoTypes(int srid) completeSql(String sql, Query<?> query) voidconfigure(PlatformConfig config) Configure the platform given the server configuration.protected voidconfigure(PlatformConfig config, boolean allQuotedIdentifiers) Configure UUID Storage etc based on DatabaseConfig settings.protected voidconfigureIdType(IdType idType) convertQuotedIdentifiers(String dbName) Convert backticks to the platform specific open quote and close quotevoidcreateSchemaIfNotExists(String dbSchema, Connection connection) Create the DB schema if it does not exist.createSequenceIdGenerator(BackgroundExecutor be, DataSource ds, int stepSize, String seqName) Return a DB Sequence based IdGenerator.protected voidescapeLikeCharacter(char ch, StringBuilder sb) escapeLikeString(String value) Escapes the like string for this DB-PlatformfromForUpdate(Query.LockWait lockWait) For update hint on the FROM clause (SQL server only).Return the BasicSqlLimiter for limit/offset of SqlQuery queries.intReturn the data type that should be used for Blob.intReturn the JDBC type used to store booleans.intReturn the data type that should be used for Clob.Return the close quote for quoted identifiers.Return the column alias prefix.Return the mapping for DB column default values.Return the DbEncrypt handler for this DB platform.Return the DB identity/sequence features for this platform.Return the mapping of JDBC to DB types.Return the history support for this database platform.getLikeClause(boolean rawLikeExpression) Returns the like clause used by this database platform.intReturn the maximum constraint name allowed for the platform.intReturn the maximum number of bind values this database platform allows or zero for no limit.intReturn the maximum table name length.getName()Return the name of the underlying Platform in lowercase.Return the behaviour to use when ending a read only transaction.Return the open quote for quoted identifiers.io.ebean.annotation.PersistBatchReturn the platform default JDBC batch mode for persist cascade.io.ebean.annotation.PlatformReturn the platform key.Return the SqlLimiter used to apply additional sql around a query to limit its results.booleanReturn true if the collation is case sensitive.booleanReturn true if the ResultSet TYPE_FORWARD_ONLY Hint should be used on findIterate() and findVisit() PreparedStatements.booleanReturn true if a compound ID in (...) type expression needs to be in expanded form of (a=? and b=?) or (a=? and b=?) or ...booleanReturn true if the platform supports LIMIT with sql update.booleanSo no except for Postgres and CockroachDB.booleanReturn true if the DB supports native UUID.booleanisPlatform(io.ebean.annotation.Platform platform) Return true if this matches the given platform.booleanSet to true if select count against anonymous view requires an alias.booleanReturn true if select count with subquery needs column alias (SQL Server).booleanReturn true if we are using Sequence batch mode rather than STEP.booleanReturn true if the platform supports delete statements with table alias.booleanReturn true if this database platform supports native ILIKE expression.booleanReturn true if the ResultSet CONCUR_UPDATABLE Hint should be used on createNativeSqlTree() PreparedStatements.booleanReturn true if the platform supports SavepointId values.booleanReturn true if empty strings should be treated as null.booleanReturn true if migrations should use stored procedures.booleanschemaExists(String dbSchema, Connection connection) Return true if the schema exists.voidsetColumnAliasPrefix(String columnAliasPrefix) Set the column alias prefix.voidsetDbEncrypt(DbEncrypt dbEncrypt) Set the DbEncrypt handler for this DB platform.voidsetDbFalseLiteral(String dbFalseLiteral) Set the DB FALSE literal (from the registered boolean ScalarType)voidsetDbTrueLiteral(String dbTrueLiteral) Set the DB TRUE literal (from the registered boolean ScalarType)voidsetForwardOnlyHintOnFindIterate(boolean forwardOnlyHintOnFindIterate) Set to true if the ResultSet TYPE_FORWARD_ONLY Hint should be used by default on findIterate PreparedStatements.voidsetHistorySupport(DbHistorySupport historySupport) Set the history support for this database platform.voidsetOnQueryOnly(DatabasePlatform.OnQueryOnly onQueryOnly) Set the behaviour to use when ending a read only transaction.voidsetSequenceBatchMode(boolean sequenceBatchMode) Set to false to not use sequence batch mode but instead STEP mode.voidsetSupportsResultSetConcurrencyModeUpdatable(boolean supportsResultSetConcurrencyModeUpdatable) Set to true if the ResultSet CONCUR_UPDATABLE Hint should be used by default on createNativeSqlTree() PreparedStatements.voidsetUseMigrationStoredProcedures(boolean useMigrationStoredProcedures) booleanbooleantableExists(Connection connection, String catalog, String schema, String table) Return true if the table exists.tablePartitionInit(String tableName, io.ebean.annotation.PartitionMode mode, String property, String singlePrimaryKey) Return the SQL to create an initial partition for the given table.booleantablePartitionsExist(Connection connection, String table) Return true if partitions exist for the given table.javax.persistence.PersistenceExceptiontranslate(String message, SQLException e) Translate the SQLException into a specific persistence exception if possible.truncateStatement(String table) Return a statement to truncate a table.Remove quoted identifier quotes from the table or column name if present.booleanReturn true if the JDBC driver does not allow additional queries to execute when a resultSet is being 'streamed' as is the case with findEach() etc.protected StringwithForUpdate(String sql, Query.LockWait lockWait, Query.LockType lockType)
-
Field Details
-
useExtraTransactionOnIterateSecondaryQueries
protected boolean useExtraTransactionOnIterateSecondaryQueriesSet to true for MySql, no other jdbc drivers need this workaround. -
supportsDeleteTableAlias
protected boolean supportsDeleteTableAlias -
supportsSavepointId
protected boolean supportsSavepointId -
useMigrationStoredProcedures
protected boolean useMigrationStoredProcedures -
supportsNativeJavaTime
protected boolean supportsNativeJavaTimeCan we use native java time API objects inResultSet.getObject(int, Class)andPreparedStatement.setObject(int, Object). Not all drivers (DB2 e.g.) will support this. -
onQueryOnly
The behaviour used when ending a read only transaction at read committed isolation level. -
openQuote
The open quote used by quoted identifiers. -
closeQuote
The close quote used by quoted identifiers. -
allQuotedIdentifiers
protected boolean allQuotedIdentifiersWhen set to true all db column names and table names use quoted identifiers. -
caseSensitiveCollation
protected boolean caseSensitiveCollation -
inlineSqlUpdateLimit
protected boolean inlineSqlUpdateLimitSet true if the Database support LIMIT clause on sql update. -
sqlLimiter
For limit/offset, row_number etc limiting of SQL queries. -
basicSqlLimiter
Limit/offset support for SqlQuery only. -
dbTypeMap
Mapping of JDBC to Database types. -
dbDefaultValue
Default values for DB columns. -
nativeUuidType
protected boolean nativeUuidTypeSet to true if the DB has native UUID type support. -
dbIdentity
Defines DB identity/sequence features. -
sequenceBatchMode
protected boolean sequenceBatchMode -
sequenceBatchSize
protected int sequenceBatchSize -
historySupport
The history support for this database platform. -
booleanDbType
protected int booleanDbTypeThe JDBC type to map booleans to (by default). -
blobDbType
protected int blobDbTypeThe JDBC type to map Blob to. -
clobDbType
protected int clobDbTypeThe JDBC type to map Clob to. -
treatEmptyStringsAsNull
protected boolean treatEmptyStringsAsNullFor Oracle treat empty strings as null. -
platform
protected io.ebean.annotation.Platform platformThe database platform name. -
truncateTable
-
columnAliasPrefix
-
likeClauseRaw
The non-escaped like clause (to stop slash being escaped on some platforms). Used for the 'raw like' expression but not for startsWith, endsWith and contains expressions. -
likeClauseEscaped
Escaped like clause for startsWith, endsWith and contains. -
likeEscapeChar
protected char likeEscapeCharEscape character used for startsWith, endsWith and contains. -
likeSpecialCharacters
protected char[] likeSpecialCharactersCharacters escaped for startsWith, endsWith and contains. -
dbEncrypt
-
idInExpandedForm
protected boolean idInExpandedForm -
selectCountWithAlias
protected boolean selectCountWithAlias -
selectCountWithColumnAlias
protected boolean selectCountWithColumnAlias -
forwardOnlyHintOnFindIterate
protected boolean forwardOnlyHintOnFindIterateIf set then use the FORWARD ONLY hint when creating ResultSets for findIterate() and findVisit(). -
supportsResultSetConcurrencyModeUpdatable
protected boolean supportsResultSetConcurrencyModeUpdatableIf set then use the CONCUR_UPDATABLE hint when creating ResultSets.This is
falsefor HANA -
persistBatchOnCascade
protected io.ebean.annotation.PersistBatch persistBatchOnCascadeBy default we use JDBC batch when cascading (except for SQL Server and HANA). -
maxInBinding
protected int maxInBinding -
maxTableNameLength
protected int maxTableNameLengthThe maximum length of table names - used specifically when derived default table names for intersection tables. -
maxConstraintNameLength
protected int maxConstraintNameLengthA value of 60 is a reasonable default for all databases except Oracle (limited to 30) and DB2 (limited to 18). -
supportsNativeIlike
protected boolean supportsNativeIlike -
exceptionTranslator
-
-
Constructor Details
-
DatabasePlatform
public DatabasePlatform()Instantiates a new database platform.
-
-
Method Details
-
translate
Translate the SQLException into a specific persistence exception if possible. -
configure
Configure the platform given the server configuration. -
configure
Configure UUID Storage etc based on DatabaseConfig settings. -
configureIdType
-
addGeoTypes
protected void addGeoTypes(int srid) -
isPlatform
public boolean isPlatform(io.ebean.annotation.Platform platform) Return true if this matches the given platform. -
getPlatform
public io.ebean.annotation.Platform getPlatform()Return the platform key. -
getName
Return the name of the underlying Platform in lowercase."generic" is returned when no specific database platform has been set or found.
-
isSequenceBatchMode
public boolean isSequenceBatchMode()Return true if we are using Sequence batch mode rather than STEP. -
setSequenceBatchMode
public void setSequenceBatchMode(boolean sequenceBatchMode) Set to false to not use sequence batch mode but instead STEP mode. -
isSupportsNativeIlike
public boolean isSupportsNativeIlike()Return true if this database platform supports native ILIKE expression. -
isSupportsDeleteTableAlias
public boolean isSupportsDeleteTableAlias()Return true if the platform supports delete statements with table alias. -
isCaseSensitiveCollation
public boolean isCaseSensitiveCollation()Return true if the collation is case sensitive.This is expected to be used for testing only.
-
isSupportsSavepointId
public boolean isSupportsSavepointId()Return true if the platform supports SavepointId values. -
isUseMigrationStoredProcedures
public boolean isUseMigrationStoredProcedures()Return true if migrations should use stored procedures. -
isInlineSqlUpdateLimit
public boolean isInlineSqlUpdateLimit()Return true if the platform supports LIMIT with sql update. -
getMaxInBinding
public int getMaxInBinding()Return the maximum number of bind values this database platform allows or zero for no limit. -
getMaxTableNameLength
public int getMaxTableNameLength()Return the maximum table name length.This is used when deriving names of intersection tables.
-
getMaxConstraintNameLength
public int getMaxConstraintNameLength()Return the maximum constraint name allowed for the platform. -
useExtraTransactionOnIterateSecondaryQueries
public boolean useExtraTransactionOnIterateSecondaryQueries()Return true if the JDBC driver does not allow additional queries to execute when a resultSet is being 'streamed' as is the case with findEach() etc.Honestly, this is a workaround for a stupid MySql JDBC driver limitation.
-
createSequenceIdGenerator
public PlatformIdGenerator createSequenceIdGenerator(BackgroundExecutor be, DataSource ds, int stepSize, String seqName) Return a DB Sequence based IdGenerator.- Parameters:
be- the BackgroundExecutor that can be used to load the sequence if desiredds- the DataSourcestepSize- the sequence allocation size as defined by mapping (defaults to 50)seqName- the name of the sequence
-
getOnQueryOnly
Return the behaviour to use when ending a read only transaction. -
setOnQueryOnly
Set the behaviour to use when ending a read only transaction. -
getDbEncrypt
Return the DbEncrypt handler for this DB platform. -
setDbEncrypt
Set the DbEncrypt handler for this DB platform. -
getHistorySupport
Return the history support for this database platform. -
setHistorySupport
Set the history support for this database platform. -
isNativeArrayType
public boolean isNativeArrayType()So no except for Postgres and CockroachDB. -
isNativeUuidType
public boolean isNativeUuidType()Return true if the DB supports native UUID. -
getDbTypeMap
Return the mapping of JDBC to DB types.- Returns:
- the db type map
-
getDbDefaultValue
Return the mapping for DB column default values. -
getColumnAliasPrefix
Return the column alias prefix. -
setColumnAliasPrefix
Set the column alias prefix. -
getCloseQuote
Return the close quote for quoted identifiers. -
getOpenQuote
Return the open quote for quoted identifiers. -
getBooleanDbType
public int getBooleanDbType()Return the JDBC type used to store booleans. -
getBlobDbType
public int getBlobDbType()Return the data type that should be used for Blob.This is typically Types.BLOB but for Postgres is Types.LONGVARBINARY for example.
-
getClobDbType
public int getClobDbType()Return the data type that should be used for Clob.This is typically Types.CLOB but for Postgres is Types.VARCHAR.
-
isTreatEmptyStringsAsNull
public boolean isTreatEmptyStringsAsNull()Return true if empty strings should be treated as null.- Returns:
- true, if checks if is treat empty strings as null
-
isIdInExpandedForm
public boolean isIdInExpandedForm()Return true if a compound ID in (...) type expression needs to be in expanded form of (a=? and b=?) or (a=? and b=?) or ... rather than (a,b) in ((?,?),(?,?),...); -
isForwardOnlyHintOnFindIterate
public boolean isForwardOnlyHintOnFindIterate()Return true if the ResultSet TYPE_FORWARD_ONLY Hint should be used on findIterate() and findVisit() PreparedStatements.This specifically is required for MySql when processing large results.
-
setForwardOnlyHintOnFindIterate
public void setForwardOnlyHintOnFindIterate(boolean forwardOnlyHintOnFindIterate) Set to true if the ResultSet TYPE_FORWARD_ONLY Hint should be used by default on findIterate PreparedStatements. -
isSupportsResultSetConcurrencyModeUpdatable
public boolean isSupportsResultSetConcurrencyModeUpdatable()Return true if the ResultSet CONCUR_UPDATABLE Hint should be used on createNativeSqlTree() PreparedStatements.This specifically is required for Hana which doesn't support CONCUR_UPDATABLE
-
setSupportsResultSetConcurrencyModeUpdatable
public void setSupportsResultSetConcurrencyModeUpdatable(boolean supportsResultSetConcurrencyModeUpdatable) Set to true if the ResultSet CONCUR_UPDATABLE Hint should be used by default on createNativeSqlTree() PreparedStatements. -
setUseMigrationStoredProcedures
public void setUseMigrationStoredProcedures(boolean useMigrationStoredProcedures) -
getDbIdentity
Return the DB identity/sequence features for this platform.- Returns:
- the db identity
-
getSqlLimiter
Return the SqlLimiter used to apply additional sql around a query to limit its results.Basically add the clauses for limit/offset, rownum, row_number().
- Returns:
- the sql limiter
-
getBasicSqlLimiter
Return the BasicSqlLimiter for limit/offset of SqlQuery queries. -
setDbTrueLiteral
Set the DB TRUE literal (from the registered boolean ScalarType) -
setDbFalseLiteral
Set the DB FALSE literal (from the registered boolean ScalarType) -
convertQuotedIdentifiers
Convert backticks to the platform specific open quote and close quoteSpecific plugins may implement this method to cater for platform specific naming rules.
- Parameters:
dbName- the db table or column name- Returns:
- the db table or column name with potentially platform specific quoted identifiers
-
unQuote
Remove quoted identifier quotes from the table or column name if present. -
isSelectCountWithAlias
public boolean isSelectCountWithAlias()Set to true if select count against anonymous view requires an alias. -
isSelectCountWithColumnAlias
public boolean isSelectCountWithColumnAlias()Return true if select count with subquery needs column alias (SQL Server). -
completeSql
-
fromForUpdate
For update hint on the FROM clause (SQL server only). -
withForUpdate
-
getLikeClause
Returns the like clause used by this database platform.This may include an escape clause to disable a default escape character.
-
getPersistBatchOnCascade
public io.ebean.annotation.PersistBatch getPersistBatchOnCascade()Return the platform default JDBC batch mode for persist cascade. -
truncateStatement
Return a statement to truncate a table. -
createSchemaIfNotExists
Create the DB schema if it does not exist.- Throws:
SQLException
-
schemaExists
Return true if the schema exists.- Throws:
SQLException
-
tableExists
public boolean tableExists(Connection connection, String catalog, String schema, String table) throws SQLException Return true if the table exists.- Throws:
SQLException
-
tablePartitionsExist
Return true if partitions exist for the given table.- Throws:
SQLException
-
tablePartitionInit
public String tablePartitionInit(String tableName, io.ebean.annotation.PartitionMode mode, String property, String singlePrimaryKey) Return the SQL to create an initial partition for the given table. -
escapeLikeString
Escapes the like string for this DB-Platform -
escapeLikeCharacter
-
supportsNativeJavaTime
public boolean supportsNativeJavaTime()
-