public class DatabasePlatform extends Object
Modifier and Type | Class and Description |
---|---|
static class |
DatabasePlatform.OnQueryOnly
Behavior used when ending a query only transaction (at read committed isolation level).
|
Constructor and Description |
---|
DatabasePlatform()
Instantiates a new database platform.
|
Modifier and Type | Method and Description |
---|---|
String |
completeSql(String sql,
Query<?> query) |
void |
configure(PlatformConfig config)
Configure the platform given the server configuration.
|
String |
convertQuotedIdentifiers(String dbName)
Convert backticks to the platform specific open quote and close quote
|
void |
createSchemaIfNotExists(String dbSchema,
Connection connection)
Create the DB schema if it does not exist.
|
PlatformIdGenerator |
createSequenceIdGenerator(BackgroundExecutor be,
DataSource ds,
int stepSize,
String seqName)
Return a DB Sequence based IdGenerator.
|
String |
escapeLikeString(String value)
Escapes the like string for this DB-Platform
|
String |
fromForUpdate(Query.ForUpdate forUpdateMode)
For update hint on the FROM clause (SQL server only).
|
BasicSqlLimiter |
getBasicSqlLimiter()
Return the BasicSqlLimiter for limit/offset of SqlQuery queries.
|
int |
getBlobDbType()
Return the data type that should be used for Blob.
|
int |
getBooleanDbType()
Return the JDBC type used to store booleans.
|
int |
getClobDbType()
Return the data type that should be used for Clob.
|
String |
getCloseQuote()
Return the close quote for quoted identifiers.
|
String |
getColumnAliasPrefix()
Return the column alias prefix.
|
DbDefaultValue |
getDbDefaultValue()
Return the mapping for DB column default values.
|
DbEncrypt |
getDbEncrypt()
Return the DbEncrypt handler for this DB platform.
|
DbIdentity |
getDbIdentity()
Return the DB identity/sequence features for this platform.
|
DbPlatformTypeMapping |
getDbTypeMap()
Return the mapping of JDBC to DB types.
|
DbHistorySupport |
getHistorySupport()
Return the history support for this database platform.
|
String |
getLikeClause(boolean rawLikeExpression)
Returns the like clause used by this database platform.
|
int |
getMaxConstraintNameLength()
Return the maximum constraint name allowed for the platform.
|
int |
getMaxTableNameLength()
Return the maximum table name length.
|
String |
getName()
Return the name of the underlying Platform in lowercase.
|
DatabasePlatform.OnQueryOnly |
getOnQueryOnly()
Return the behaviour to use when ending a read only transaction.
|
String |
getOpenQuote()
Return the open quote for quoted identifiers.
|
io.ebean.annotation.PersistBatch |
getPersistBatchOnCascade()
Return the platform default JDBC batch mode for persist cascade.
|
io.ebean.annotation.Platform |
getPlatform()
Return the platform key.
|
SqlLimiter |
getSqlLimiter()
Return the SqlLimiter used to apply additional sql around a query to limit
its results.
|
String |
getTableAliasPlaceHolder()
Return the table alias placeholder.
|
boolean |
isDdlCommitOnCreateIndex()
Normally not needed - overridden in CockroachPlatform.
|
boolean |
isForwardOnlyHintOnFindIterate()
Return true if the ResultSet TYPE_FORWARD_ONLY Hint should be used on
findIterate() and findVisit() PreparedStatements.
|
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 ...
|
boolean |
isNativeArrayType()
So no except for Postgres and CockroachDB.
|
boolean |
isNativeUuidType()
Return true if the DB supports native UUID.
|
boolean |
isPlatform(io.ebean.annotation.Platform platform)
Return true if this matches the given platform.
|
boolean |
isSelectCountWithAlias()
Set to true if select count against anonymous view requires an alias.
|
boolean |
isSequenceBatchMode()
Return true if we are using Sequence batch mode rather than STEP.
|
boolean |
isSupportsNativeIlike()
Return true if this database platform supports native ILIKE expression.
|
boolean |
isSupportsResultSetConcurrencyModeUpdatable()
Return true if the ResultSet CONCUR_UPDATABLE Hint should be used on
createNativeSqlTree() PreparedStatements.
|
boolean |
isTreatEmptyStringsAsNull()
Return true if empty strings should be treated as null.
|
boolean |
schemaExists(String dbSchema,
Connection connection)
Return true if the schema exists.
|
void |
setColumnAliasPrefix(String columnAliasPrefix)
Set the column alias prefix.
|
void |
setDbEncrypt(DbEncrypt dbEncrypt)
Set the DbEncrypt handler for this DB platform.
|
void |
setDbFalseLiteral(String dbFalseLiteral)
Set the DB FALSE literal (from the registered boolean ScalarType)
|
void |
setDbTrueLiteral(String dbTrueLiteral)
Set the DB TRUE literal (from the registered boolean ScalarType)
|
void |
setForwardOnlyHintOnFindIterate(boolean forwardOnlyHintOnFindIterate)
Set to true if the ResultSet TYPE_FORWARD_ONLY Hint should be used by default on findIterate PreparedStatements.
|
void |
setHistorySupport(DbHistorySupport historySupport)
Set the history support for this database platform.
|
void |
setOnQueryOnly(DatabasePlatform.OnQueryOnly onQueryOnly)
Set the behaviour to use when ending a read only transaction.
|
void |
setSequenceBatchMode(boolean sequenceBatchMode)
Set to false to not use sequence batch mode but instead STEP mode.
|
void |
setSupportsResultSetConcurrencyModeUpdatable(boolean supportsResultSetConcurrencyModeUpdatable)
Set to true if the ResultSet CONCUR_UPDATABLE Hint should be used by default on createNativeSqlTree() PreparedStatements.
|
void |
setTableAliasPlaceHolder(String tableAliasPlaceHolder)
Set the table alias placeholder.
|
boolean |
tableExists(Connection connection,
String catalog,
String schema,
String table)
Return true if the table exists.
|
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.
|
boolean |
tablePartitionsExist(Connection connection,
String table)
Return true if partitions exist for the given table.
|
javax.persistence.PersistenceException |
translate(String message,
SQLException e)
Translate the SQLException into a specific persistence exception if possible.
|
String |
unQuote(String dbName)
Remove quoted identifier quotes from the table or column name if present.
|
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.
|
public DatabasePlatform()
public javax.persistence.PersistenceException translate(String message, SQLException e)
public void configure(PlatformConfig config)
public boolean isPlatform(io.ebean.annotation.Platform platform)
public io.ebean.annotation.Platform getPlatform()
public String getName()
"generic" is returned when no specific database platform has been set or found.
public boolean isSequenceBatchMode()
public void setSequenceBatchMode(boolean sequenceBatchMode)
public boolean isSupportsNativeIlike()
public int getMaxTableNameLength()
This is used when deriving names of intersection tables.
public int getMaxConstraintNameLength()
public boolean useExtraTransactionOnIterateSecondaryQueries()
Honestly, this is a workaround for a stupid MySql JDBC driver limitation.
public PlatformIdGenerator createSequenceIdGenerator(BackgroundExecutor be, DataSource ds, int stepSize, String seqName)
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 sequencepublic DatabasePlatform.OnQueryOnly getOnQueryOnly()
public void setOnQueryOnly(DatabasePlatform.OnQueryOnly onQueryOnly)
public DbEncrypt getDbEncrypt()
public void setDbEncrypt(DbEncrypt dbEncrypt)
public DbHistorySupport getHistorySupport()
public void setHistorySupport(DbHistorySupport historySupport)
public boolean isNativeArrayType()
public boolean isNativeUuidType()
public DbPlatformTypeMapping getDbTypeMap()
public DbDefaultValue getDbDefaultValue()
public String getColumnAliasPrefix()
public void setColumnAliasPrefix(String columnAliasPrefix)
public String getTableAliasPlaceHolder()
public void setTableAliasPlaceHolder(String tableAliasPlaceHolder)
public String getCloseQuote()
public String getOpenQuote()
public int getBooleanDbType()
public int getBlobDbType()
This is typically Types.BLOB but for Postgres is Types.LONGVARBINARY for example.
public int getClobDbType()
This is typically Types.CLOB but for Postgres is Types.VARCHAR.
public boolean isTreatEmptyStringsAsNull()
public boolean isIdInExpandedForm()
public boolean isForwardOnlyHintOnFindIterate()
This specifically is required for MySql when processing large results.
public void setForwardOnlyHintOnFindIterate(boolean forwardOnlyHintOnFindIterate)
public boolean isSupportsResultSetConcurrencyModeUpdatable()
This specifically is required for Hana which doesn't support CONCUR_UPDATABLE
public void setSupportsResultSetConcurrencyModeUpdatable(boolean supportsResultSetConcurrencyModeUpdatable)
public boolean isDdlCommitOnCreateIndex()
public DbIdentity getDbIdentity()
public SqlLimiter getSqlLimiter()
Basically add the clauses for limit/offset, rownum, row_number().
public BasicSqlLimiter getBasicSqlLimiter()
public void setDbTrueLiteral(String dbTrueLiteral)
public void setDbFalseLiteral(String dbFalseLiteral)
public String convertQuotedIdentifiers(String dbName)
Specific plugins may implement this method to cater for platform specific naming rules.
dbName
- the db table or column namepublic String unQuote(String dbName)
public boolean isSelectCountWithAlias()
public String completeSql(String sql, Query<?> query)
public String fromForUpdate(Query.ForUpdate forUpdateMode)
public String getLikeClause(boolean rawLikeExpression)
This may include an escape clause to disable a default escape character.
public io.ebean.annotation.PersistBatch getPersistBatchOnCascade()
public void createSchemaIfNotExists(String dbSchema, Connection connection) throws SQLException
SQLException
public boolean schemaExists(String dbSchema, Connection connection) throws SQLException
SQLException
public boolean tableExists(Connection connection, String catalog, String schema, String table) throws SQLException
SQLException
public boolean tablePartitionsExist(Connection connection, String table) throws SQLException
SQLException
public String tablePartitionInit(String tableName, io.ebean.annotation.PartitionMode mode, String property, String singlePrimaryKey)
public String escapeLikeString(String value)
Copyright © 2019. All rights reserved.