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).
|
| Modifier and Type | Field and Description |
|---|---|
protected BasicSqlLimiter |
basicSqlLimiter
Limit/offset support for SqlQuery only.
|
protected int |
blobDbType
The JDBC type to map Blob to.
|
protected int |
booleanDbType
The JDBC type to map booleans to (by default).
|
protected int |
clobDbType
The JDBC type to map Clob to.
|
protected String |
closeQuote
The close quote used by quoted identifiers.
|
protected String |
columnAliasPrefix |
protected DbDefaultValue |
dbDefaultValue
Default values for DB columns.
|
protected DbEncrypt |
dbEncrypt |
protected DbIdentity |
dbIdentity
Defines DB identity/sequence features.
|
protected DbTypeMap |
dbTypeMap
Mapping of JDBC to Database types.
|
protected boolean |
forwardOnlyHintOnFindIterate
If set then use the FORWARD ONLY hint when creating ResultSets for
findIterate() and findVisit().
|
protected DbHistorySupport |
historySupport
The history support for this database platform.
|
protected boolean |
idInExpandedForm |
protected String |
likeClause
The like clause.
|
protected int |
maxConstraintNameLength
A value of 60 is a reasonable default for all databases except
Oracle (limited to 30) and DB2 (limited to 18).
|
protected int |
maxTableNameLength
The maximum length of table names - used specifically when derived
default table names for intersection tables.
|
protected String |
name
The database platform name.
|
protected boolean |
nativeUuidType
Set to true if the DB has native UUID type support.
|
protected DatabasePlatform.OnQueryOnly |
onQueryOnly
The behaviour used when ending a read only transaction at read committed isolation level.
|
protected String |
openQuote
The open quote used by quoted identifiers.
|
protected PersistBatch |
persistBatchOnCascade
By default we use JDBC batch when cascading (except for SQL Server).
|
protected com.avaje.ebean.dbmigration.ddlgeneration.platform.PlatformDdl |
platformDdl |
protected boolean |
selectCountWithAlias |
protected SqlLimiter |
sqlLimiter
For limit/offset, row_number etc limiting of SQL queries.
|
protected boolean |
supportsNativeIlike |
protected String |
tableAliasPlaceHolder |
protected boolean |
treatEmptyStringsAsNull
For Oracle treat empty strings as null.
|
protected boolean |
useExtraTransactionOnIterateSecondaryQueries
Set to true for MySql, no other jdbc drivers need this workaround.
|
| Constructor and Description |
|---|
DatabasePlatform()
Instantiates a new database platform.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
close(ResultSet resultSet)
Close the resultSet.
|
String |
completeSql(String sql,
Query<?> query) |
void |
configure(ServerConfig serverConfig)
Configure UUID Storage etc based on ServerConfig settings.
|
String |
convertQuotedIdentifiers(String dbName)
Convert backticks to the platform specific open quote and close quote
|
com.avaje.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.
|
DbTypeMap |
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 DatabasePlatform.
|
DatabasePlatform.OnQueryOnly |
getOnQueryOnly()
Return the behaviour to use when ending a read only transaction.
|
String |
getOpenQuote()
Return the open quote for quoted identifiers.
|
PersistBatch |
getPersistBatchOnCascade()
Return the platform default JDBC batch mode for persist cascade.
|
com.avaje.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 |
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.
|
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.
|
protected String |
withForUpdate(String sql) |
protected boolean useExtraTransactionOnIterateSecondaryQueries
protected DatabasePlatform.OnQueryOnly onQueryOnly
protected String closeQuote
protected SqlLimiter sqlLimiter
protected BasicSqlLimiter basicSqlLimiter
protected DbDefaultValue dbDefaultValue
protected boolean nativeUuidType
protected DbIdentity dbIdentity
protected DbHistorySupport historySupport
protected int booleanDbType
protected int blobDbType
protected int clobDbType
protected boolean treatEmptyStringsAsNull
protected String columnAliasPrefix
protected String tableAliasPlaceHolder
protected String likeClause
protected boolean idInExpandedForm
protected boolean selectCountWithAlias
protected boolean forwardOnlyHintOnFindIterate
protected PersistBatch persistBatchOnCascade
protected com.avaje.ebean.dbmigration.ddlgeneration.platform.PlatformDdl platformDdl
protected int maxTableNameLength
protected int maxConstraintNameLength
protected boolean supportsNativeIlike
public DatabasePlatform()
public void configure(ServerConfig serverConfig)
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 com.avaje.ebean.dbmigration.ddlgeneration.platform.PlatformDdl getPlatformDdl()
public com.avaje.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 DbTypeMap 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)
protected String withForUpdate(String sql)
public String getLikeClause()
This may include an escape clause to disable a default escape character.
public PersistBatch getPersistBatchOnCascade()
public boolean tableExists(Connection connection, String catalog, String schema, String table) throws SQLException
SQLExceptionCopyright © 2016. All rights reserved.