Class DefaultDbEngine

java.lang.Object
net.sf.basedb.core.dbengine.AbstractDbEngine
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: 2016-02-15 11:58:10 +0100 (må, 15 feb 2016) $
  • Constructor Details

    • DefaultDbEngine

      public DefaultDbEngine()
      Create DefaultDbEngine.
  • Method Details

    • getCreateSchemaSql

      public String getCreateSchemaSql(String catalog, String schema)
      Generate create schema <catalog>.<schema>.
      Since:
      3.4
    • 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:
    • 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:
    • 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