com.avaje.ebean.config.dbplatform
Class DatabasePlatform

java.lang.Object
  extended by com.avaje.ebean.config.dbplatform.DatabasePlatform
Direct Known Subclasses:
DB2Platform, H2Platform, MsSqlServer2000Platform, MsSqlServer2005Platform, MySqlPlatform, Oracle10Platform, PostgresPlatform, SQLitePlatform

public class DatabasePlatform
extends Object

    

Database platform specific settings.


Constructor Summary
DatabasePlatform()
          Instantiates a new database platform.
 
Method Summary
 String convertQuotedIdentifiers(String dbName)
          Convert backticks to the platform specific open quote and close quote
 IdGenerator createSequenceIdGenerator(BackgroundExecutor be, DataSource ds, String seqName, int batchSize)
          Return a DB Sequence based IdGenerator.
 int getBlobDbType()
          Return the data type that should be used for Blob.
 int getBooleanDbType()
          Return the JDBC type used to store booleans.
 String getCloseQuote()
          Return the close quote for quoted identifiers.
 DbDdlSyntax getDbDdlSyntax()
          Return the DDL syntax for this platform.
 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.
 String getName()
          Return the name of the DatabasePlatform.
 String getOpenQuote()
          Return the open quote for quoted identifiers.
 SqlLimiter getSqlLimiter()
          Return the SqlLimiter used to apply additional sql around a query to limit its results.
 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 isTreatEmptyStringsAsNull()
          Return true if empty strings should be treated as null.
 void setDbEncrypt(DbEncrypt dbEncrypt)
          Set the DbEncrypt handler for this DB platform.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabasePlatform

public DatabasePlatform()
Instantiates a new database platform.

Method Detail

getName

public String getName()
Return the name of the DatabasePlatform.

"generic" is returned when no specific database platform has been set or found.

Returns:
the name

createSequenceIdGenerator

public IdGenerator createSequenceIdGenerator(BackgroundExecutor be,
                                             DataSource ds,
                                             String seqName,
                                             int batchSize)
Return a DB Sequence based IdGenerator.

Parameters:
be - the BackgroundExecutor that can be used to load the sequence if desired
ds - the DataSource
seqName - the name of the sequence
batchSize - the number of sequences that should be loaded

getDbEncrypt

public DbEncrypt getDbEncrypt()
Return the DbEncrypt handler for this DB platform.


setDbEncrypt

public void setDbEncrypt(DbEncrypt dbEncrypt)
Set the DbEncrypt handler for this DB platform.


getDbTypeMap

public DbTypeMap getDbTypeMap()
Return the mapping of JDBC to DB types.

Returns:
the db type map

getDbDdlSyntax

public DbDdlSyntax getDbDdlSyntax()
Return the DDL syntax for this platform.

Returns:
the db ddl syntax

getCloseQuote

public String getCloseQuote()
Return the close quote for quoted identifiers.

Returns:
the close quote

getOpenQuote

public String getOpenQuote()
Return the open quote for quoted identifiers.

Returns:
the open quote

getBooleanDbType

public int getBooleanDbType()
Return the JDBC type used to store booleans.

Returns:
the boolean db type

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.


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 ((?,?),(?,?),...);


getDbIdentity

public DbIdentity getDbIdentity()
Return the DB identity/sequence features for this platform.

Returns:
the db identity

getSqlLimiter

public SqlLimiter 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

convertQuotedIdentifiers

public String convertQuotedIdentifiers(String dbName)
Convert backticks to the platform specific open quote and close quote

Specific plugins may implement this method to cater for platform specific naming rules.

Parameters:
dbName - the db name
Returns:
the string


Copyright © 2010. All Rights Reserved.