org.melati.poem.dbms
Class Hsqldb

Package class diagram package Hsqldb
java.lang.Object
  extended by org.melati.poem.dbms.AnsiStandard
      extended by org.melati.poem.dbms.Hsqldb
All Implemented Interfaces:
Dbms
Direct Known Subclasses:
HsqldbText

public class Hsqldb
extends AnsiStandard

A Driver for HSQLDB (http://www.hsqldb.org/). Note that HSQLDB uppercases any name that isn't quoted.


Field Summary
static int hsqldbTextHack
          HSQLDB does not have a pleasant TEXT datatype, so we use an arbetary value in a VARCHAR.
 
Fields inherited from class org.melati.poem.dbms.AnsiStandard
schema
 
Constructor Summary
Hsqldb()
          Constructor.
 
Method Summary
 PoemType canRepresent(PoemType storage, PoemType type)
          Accomodate our String size hack.
 String caseInsensitiveRegExpSQL(String term1, String term2)
          Note that this is NOT case insensitive.
 String createTableTypeQualifierSql(Table table)
          The default is to keep everything in memory, this allows for the db to be written to the disk.
 String getBinarySqlDefinition(int size)
          Accomodate different treatment of different sized binary data.
 String getForeignKeyDefinition(String tableName, String fieldName, String targetTableName, String targetTableFieldName, String fixName)
          If Foreign key definitions are part of field definitions, otherwise blank (silently unsupported).
 String getJdbcMetadataName(String name)
          Bad smell.
 String getLongSqlDefinition()
          Accomodate Long / Bigint deviants.
 String getStringSqlDefinition(int size)
          Accomodate String / Text distinction.
 String melatiName(String name)
          Reverse the mapping in unreservedName.
 void shutdown(Connection connection)
          Shut the db down nicely.
 String unreservedName(String name)
          A pair of functions for getting around keywords which make your JDBC driver barf, as 'group' does for MySQL.
 
Methods inherited from class org.melati.poem.dbms.AnsiStandard
alterColumnNotNullableSQL, booleanTrueExpression, canBeIndexed, canDropColumns, canStoreBlobs, createTableOptionsSql, createTableSql, defaultPoemTypeOfColumnMetaData, exceptionForUpdate, exceptionForUpdate, getConnection, getDriverClassName, getDriverLoaded, getFixedPtSqlDefinition, getIndexLength, getPrimaryKeyDefinition, getQuotedName, getQuotedValue, getSchema, getSqlDefaultValue, getSqlDefinition, givesCapabilitySQL, loadDriver, preparedStatementPlaceholder, selectLimit, setDriverClassName, setDriverLoaded, sqlBooleanValueOfRaw, tableInitialisationSql, toString, unloadDriver
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

hsqldbTextHack

public static int hsqldbTextHack
HSQLDB does not have a pleasant TEXT datatype, so we use an arbetary value in a VARCHAR.

Constructor Detail

Hsqldb

public Hsqldb()
Constructor.

Method Detail

shutdown

public void shutdown(Connection connection)
              throws SQLException
Shut the db down nicely.

Specified by:
shutdown in interface Dbms
Overrides:
shutdown in class AnsiStandard
Throws:
SQLException
See Also:
org.melati.poem.dbms.Dbms#disconnect()

createTableTypeQualifierSql

public String createTableTypeQualifierSql(Table table)
The default is to keep everything in memory, this allows for the db to be written to the disk. Allow Hsqldb to have a different create table syntax. Should have trailing space if not empty String

Specified by:
createTableTypeQualifierSql in interface Dbms
Overrides:
createTableTypeQualifierSql in class AnsiStandard
See Also:
org.melati.poem.dbms.Dbms#createTableSql(), org.melati.poem.dbms.AnsiStandard#createTableSql()

getStringSqlDefinition

public String getStringSqlDefinition(int size)
Accomodate String / Text distinction.

Specified by:
getStringSqlDefinition in interface Dbms
Overrides:
getStringSqlDefinition in class AnsiStandard
Parameters:
size - the string length (-1 means no limit)
Returns:
the SQL definition for a string of this size
See Also:
AnsiStandard.getStringSqlDefinition(int)

getLongSqlDefinition

public String getLongSqlDefinition()
Accomodate Long / Bigint deviants.

Specified by:
getLongSqlDefinition in interface Dbms
Overrides:
getLongSqlDefinition in class AnsiStandard
Returns:
the keyword to use.
See Also:
AnsiStandard.getLongSqlDefinition()

getBinarySqlDefinition

public String getBinarySqlDefinition(int size)
                              throws SQLException
Accomodate different treatment of different sized binary data.

Specified by:
getBinarySqlDefinition in interface Dbms
Overrides:
getBinarySqlDefinition in class AnsiStandard
Parameters:
size - how big the field is
Returns:
the keyword to use
Throws:
SQLException
See Also:
AnsiStandard.getBinarySqlDefinition(int)

canRepresent

public PoemType canRepresent(PoemType storage,
                             PoemType type)
Accomodate our String size hack. Enable one PoemType to represent another, for example a bit to represent a boolean.

Specified by:
canRepresent in interface Dbms
Overrides:
canRepresent in class AnsiStandard
Parameters:
storage - the POEM native type
type - the current type
Returns:
the PoemType to use
See Also:
AnsiStandard.canRepresent(org.melati.poem.PoemType, org.melati.poem.PoemType)

unreservedName

public String unreservedName(String name)
A pair of functions for getting around keywords which make your JDBC driver barf, as 'group' does for MySQL. Translate special names to non special ones.

Specified by:
unreservedName in interface Dbms
Overrides:
unreservedName in class AnsiStandard
Parameters:
name - the field or table name
Returns:
the name translated if necessary
See Also:
AnsiStandard.unreservedName(java.lang.String)

melatiName

public String melatiName(String name)
Reverse the mapping in unreservedName.

Specified by:
melatiName in interface Dbms
Overrides:
melatiName in class AnsiStandard
Parameters:
name - an SQL name
Returns:
the coresponding name to use within Melati
See Also:
AnsiStandard.melatiName(java.lang.String)

caseInsensitiveRegExpSQL

public String caseInsensitiveRegExpSQL(String term1,
                                       String term2)
Note that this is NOT case insensitive. This is the Postgresql syntax. Accomodate the variety of ways of ignoring case.

Specified by:
caseInsensitiveRegExpSQL in interface Dbms
Overrides:
caseInsensitiveRegExpSQL in class AnsiStandard
Parameters:
term1 - the term to find in
term2 - the quoted term to find
Returns:
the SQL query to use
See Also:
Dbms.caseInsensitiveRegExpSQL(java.lang.String, java.lang.String)

getForeignKeyDefinition

public String getForeignKeyDefinition(String tableName,
                                      String fieldName,
                                      String targetTableName,
                                      String targetTableFieldName,
                                      String fixName)
If Foreign key definitions are part of field definitions, otherwise blank (silently unsupported).

Specified by:
getForeignKeyDefinition in interface Dbms
Overrides:
getForeignKeyDefinition in class AnsiStandard
Parameters:
tableName - the table that this column is in, unquoted
fieldName - often the name of the foreign table, unquoted
targetTableName - the table that this is a foreign key into, unquoted
targetTableFieldName - name of the primary key field of the foreign table, often id, unquoted
fixName - name of the IntegrityFix
Returns:
The definition string
See Also:
AnsiStandard.getForeignKeyDefinition(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)

getJdbcMetadataName

public String getJdbcMetadataName(String name)
Bad smell. Some DBMSen (HSQLDB) use canonical uppercased names in the metadata but not in normal use. see org.melati.poem.Table#unifyWithDB

Specified by:
getJdbcMetadataName in interface Dbms
Overrides:
getJdbcMetadataName in class AnsiStandard
Parameters:
name - entity name such as tableinfo
Returns:
the (un)quoted name
See Also:
AnsiStandard.getJdbcMetadataName(java.lang.String)


Copyright © 2000-2010 PanEris. All Rights Reserved.