3.2.1: 2012-12-13

net.sf.basedb.core.dbengine
Class DefaultDbEngine

java.lang.Object
  extended by net.sf.basedb.core.dbengine.AbstractDbEngine
      extended by net.sf.basedb.core.dbengine.DefaultDbEngine
All Implemented Interfaces:
DbEngine

public class DefaultDbEngine
extends AbstractDbEngine

A default DbEngine that is selected if no other can be found. This probably has some issues with most databases.

Version:
2.0
Author:
nicklas
Last modified
$Date: 2011-11-25 13:07:04 +0100 (Fri, 25 Nov 2011) $

Constructor Summary
DefaultDbEngine()
          Create DefaultDbEngine.
 
Method Summary
 boolean analyzeAfterBatchOperation()
          Return false.
 boolean caseInsensitiveComparison()
          Returns TRUE.
 String getAnalyzeTableSql(String catalog, String schema, String table)
          Return null.
 String getCreateForeignKeySql(String catalog, String schema, String table, String name, Set<String> columns, String refTable, Set<String> refColumns)
          Generates SQL that creates a foreign key constraint between two tables.
 String getCreateIndexSql(String catalog, String schema, String table, String name, Set<String> columns, boolean unique)
          Generates CREATE [UNIQUE] INDEX <name> ON <catalog>.
 String getCreatePrimaryKeySql(String catalog, String schema, String table, String name, Set<String> columns)
          Generate SQL to create a primary key for a table.
 String getDropForeignKeySql(String catalog, String schema, String table, String name)
          Generate ALTER TABLE <catalog>.
 String getDropIndexSql(String catalog, String schema, String table, String name, boolean unique)
          Generate DROP INDEX <catalog>.
 String getDropPrimaryKey(String catalog, String schema, String table, String name)
          Generate SQL that drops the primary key from a table.
 String getInsertAutoIncrementSql(PersistentClass pc)
          Return a SQL fragment that can be used in an INSERT INTO statement to generate an ID for new rows.
 String getOptimizeTableSql(String catalog, String schema, String table)
          Return null.
 
Methods inherited from class net.sf.basedb.core.dbengine.AbstractDbEngine
abs, castToDate, checkForInvalidNumberOperation, exp, getApproximateRowCountSql, getCaseSensitiveVarchar, getQuotedName, inspectSchemaGenerationSQL, isValidColumnName, isValidName, isValidTableName, ln, makeSafeCreateTable, power, rlike, selectOrderByColumnsIfDistinct, supportColumnAliasInGroupBy, supportColumnAliasInHaving, supportColumnAliasInOrderBy, supportsColumnAliasInWhere, useSavePointToContinueTransactionFromSqlFailure, useThetaJoin
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultDbEngine

public DefaultDbEngine()
Create DefaultDbEngine.

Method Detail

getCreateIndexSql

public String getCreateIndexSql(String catalog,
                                String schema,
                                String table,
                                String name,
                                Set<String> columns,
                                boolean unique)
Generates CREATE [UNIQUE] INDEX <name> ON <catalog>.<schema>.<table> (<columns>) which should work for most databases.

Parameters:
catalog - The name of the catalog (database) where the table is located, or null if it is located in the current catalog
schema - The name of the schema where the table is located, or null if is located in the current schema
table - The name of the table
name - The name of the index to be created
columns - The name of the columns in the index
unique - If the index must contain unique values or not
Returns:
The SQL to execute

getDropIndexSql

public String getDropIndexSql(String catalog,
                              String schema,
                              String table,
                              String name,
                              boolean unique)
Generate DROP INDEX <catalog>.<schema>.<table>.<name>.

Parameters:
catalog - The name of the catalog (database) where the table is located, or null if it is located in the current catalog
schema - The name of the schema where the table is located, or null if is located in the current schema
table - The name of the table
name - The name of the index
unique - If the index contains unique values or not
Returns:
The SQL to execute

getDropForeignKeySql

public String getDropForeignKeySql(String catalog,
                                   String schema,
                                   String table,
                                   String name)
Generate ALTER TABLE <catalog>.<schema>.<table> DROP CONSTRAINT <name>

Parameters:
catalog - The name of the catalog (database) where the table is located, or null if it is located in the current catalog
schema - The name of the schema where the table is located, or null if is located in the current schema
table - The name of the table
name - The name of the foreign key
Returns:
The SQL to execute
Since:
3.0

getInsertAutoIncrementSql

public String getInsertAutoIncrementSql(PersistentClass pc)
Description copied from interface: DbEngine
Return a SQL fragment that can be used in an INSERT INTO statement to generate an ID for new rows.

Parameters:
pc - The persistent class
Returns:
Always "null" (assuming that the database knows how to generate the id)

analyzeAfterBatchOperation

public boolean analyzeAfterBatchOperation()
Return false.


getOptimizeTableSql

public String getOptimizeTableSql(String catalog,
                                  String schema,
                                  String table)
Return null.

Parameters:
catalog - The name of the catalog (database) where the table is located, or null if it is located in the current catalog
schema - The name of the schema where the table is located, or null if is located in the current schema
table - The name of the table to optimize
Returns:
The SQL to execute
See Also:
DbEngine.getAnalyzeTableSql(String, String, String)

getAnalyzeTableSql

public String getAnalyzeTableSql(String catalog,
                                 String schema,
                                 String table)
Return null.

Parameters:
catalog - The name of the catalog (database) where the table is located, or null if it is located in the current catalog
schema - The name of the schema where the table is located, or null if is located in the current schema
table - The name of the table to analyze
Returns:
The SQL to execute, or null if not supported
See Also:
DbEngine.getOptimizeTableSql(String, String, String)

caseInsensitiveComparison

public boolean caseInsensitiveComparison()
Returns TRUE.

Returns:
FALSE if comparisons are case sensitive (ABC != abc), TRUE if they are case insensitive (ABC = abc)
Since:
2.4

getCreateForeignKeySql

public String getCreateForeignKeySql(String catalog,
                                     String schema,
                                     String table,
                                     String name,
                                     Set<String> columns,
                                     String refTable,
                                     Set<String> refColumns)
Description copied from interface: DbEngine
Generates SQL that creates a foreign key constraint between two tables. Note! When calling this method, ensure that the Set:s with columns have a predictable iteration order!

Parameters:
catalog - The name of the catalog (database) where the tables are located, or null if it is located in the current catalog
schema - The name of the schema where the tables are located, or null if is located in the current schema
table - The name of the foreign key table
name - The name of the foreign key
columns - The columns that make up the foreign key
refTable - The table that is referenced by the foreign key
refColumns - The columns that are referenced by the foreign key
Returns:
The SQL to create the foreign key

getCreatePrimaryKeySql

public String getCreatePrimaryKeySql(String catalog,
                                     String schema,
                                     String table,
                                     String name,
                                     Set<String> columns)
Description copied from interface: DbEngine
Generate SQL to create a primary key for a table. Note! When calling this method, ensure that the column set have a predictable iteration order!

Parameters:
catalog - The name of the catalog (database) where the table is located, or null if it is located in the current catalog
schema - The name of the schema where the table is located, or null if is located in the current schema
table - The name of the table
name - The name of the primary key
columns - The name of the columns in the primary key
Returns:
The SQL to execute

getDropPrimaryKey

public String getDropPrimaryKey(String catalog,
                                String schema,
                                String table,
                                String name)
Description copied from interface: DbEngine
Generate SQL that drops the primary key from a table.

Parameters:
catalog - The name of the catalog (database) where the table is located, or null if it is located in the current catalog
schema - The name of the schema where the table is located, or null if is located in the current schema
table - The name of the table
name - The name of the primary key
Returns:
The SQL to execute

3.2.1: 2012-12-13