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(DbTypeConfig config)
Configure UUID Storage etc based on ServerConfig settings.
|
String |
convertQuotedIdentifiers(String dbName)
Convert backticks to the platform specific open quote and close quote
|
io.ebean.dbmigration.ddlgeneration.DdlHandler |
createDdlHandler(ServerConfig serverConfig)
Create and return a DDL handler for generating DDL scripts.
|
PlatformIdGenerator |
createSequenceIdGenerator(BackgroundExecutor be,
DataSource ds,
String seqName,
int batchSize)
Return a DB Sequence based IdGenerator.
|
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()
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.PersistBatch |
getPersistBatchOnCascade()
Return the platform default JDBC batch mode for persist cascade.
|
io.ebean.Platform |
getPlatform()
Return the platform key.
|
io.ebean.dbmigration.ddlgeneration.platform.PlatformDdl |
getPlatformDdl()
Return the platform specific DDL.
|
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 |
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 |
isNativeUuidType()
Return true if the DB supports native UUID.
|
boolean |
isPlatform(io.ebean.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 |
isSupportsNativeIlike()
Return true if this database platform supports native ILIKE expression.
|
boolean |
isTreatEmptyStringsAsNull()
Return true if empty strings should be treated as null.
|
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 |
setTableAliasPlaceHolder(String tableAliasPlaceHolder)
Set the table alias placeholder.
|
boolean |
tableExists(Connection connection,
String catalog,
String schema,
String table)
Return true if the table exists.
|
javax.persistence.PersistenceException |
translate(String message,
SQLException e)
Translate the SQLException into a specific persistence exception if possible.
|
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(DbTypeConfig config)
public boolean isPlatform(io.ebean.Platform platform)
public io.ebean.Platform getPlatform()
public String getName()
"generic" is returned when no specific database platform has been set or found.
public boolean isSupportsNativeIlike()
public int getMaxTableNameLength()
This is used when deriving names of intersection tables.
public int getMaxConstraintNameLength()
public io.ebean.dbmigration.ddlgeneration.platform.PlatformDdl getPlatformDdl()
public io.ebean.dbmigration.ddlgeneration.DdlHandler createDdlHandler(ServerConfig serverConfig)
public boolean useExtraTransactionOnIterateSecondaryQueries()
Honestly, this is a workaround for a stupid MySql JDBC driver limitation.
public PlatformIdGenerator createSequenceIdGenerator(BackgroundExecutor be, DataSource ds, String seqName, int batchSize)
be
- the BackgroundExecutor that can be used to load the sequence if
desiredds
- the DataSourceseqName
- the name of the sequencebatchSize
- the number of sequences that should be loadedpublic 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 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 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 namepublic boolean isSelectCountWithAlias()
public String completeSql(String sql, Query<?> query)
public String getLikeClause()
This may include an escape clause to disable a default escape character.
public io.ebean.PersistBatch getPersistBatchOnCascade()
public boolean tableExists(Connection connection, String catalog, String schema, String table) throws SQLException
SQLException
Copyright © 2017. All rights reserved.