SolarMetric Kodo JDO 2.5.8 generated on January 11 2004

com.solarmetric.kodo.impl.jdbc.schema.dict
Class PostgresDictionary

java.lang.Object
  |
  +--com.solarmetric.kodo.impl.jdbc.schema.dict.AbstractDictionary
        |
        +--com.solarmetric.kodo.impl.jdbc.schema.dict.PostgresDictionary
All Implemented Interfaces:
DBDictionary

public class PostgresDictionary
extends AbstractDictionary

Implementation of DBDictionary for PostgreSQL. This dictionary contains workaround for various issues with the postgres JDBC driver. Most notably, the official Postgres JDBC driver cannot handle strings of length 0, either in normal or prepared statements. Thus, we need to set the String to something (we use "null").


Fields inherited from class com.solarmetric.kodo.impl.jdbc.schema.dict.AbstractDictionary
CENTI, DECI, meta, MICRO, MILLI, NANO, NUMBER_FORMAT, SEC
 
Constructor Summary
PostgresDictionary()
           
 
Method Summary
(package private) static void ()
           
 Object blobFromSQL(ResultSet rs, int column)
          Convert the specified column of the SQL ResultSet to the proper java type.
 void booleanToPreparedParameter(PreparedStatement st, int index, Boolean val)
           
 void characterToPreparedParameter(PreparedStatement st, int index, Character val)
           
 void clobToPreparedParameter(PreparedStatement st, int index, Object val)
           
 Date dateFromSQL(ResultSet rs, int column)
          Convert the specified column of the SQL ResultSet to the proper java type.
 Object dateToSQL(Date val)
          Convert data into SQL for the current database platform.
 SQLBuffer[] getAddColumnSQL(Column column)
          PostgreSQL has special needs when altering PK columns.
protected  String getAutoIncrementSequence(Column col)
          Returns the auto-increment sequence name created by Postgres for col.
protected  SQLBuffer getColumnDeclaration(Column column)
          This method can be overridden if the database does not support standard column declarations, which are in the form: <column-name> <sql-type> [NOT NULL].
protected  SQLBuffer getColumnDeclaration(Column column, boolean ignorePK)
          This method can be overridden if the database does not support standard column declarations, which are in the form: <column-name> <sql-type> [NOT NULL].
protected  int getDatePrecision()
          Return the precision to which dates are stored in this type of data store.
 SQLBuffer[] getDropColumnSQL(Column column)
          PostgreSQL can't deal with dropping columns.
 long getNextAutoIncrementValue(Table table, SQLExecutionManager sqlem)
          Returns the next auto-increment value for a given table.
 String getPlatform()
          Return the title of this database platform, used for display only.
 String getValidIndexName(String name)
          Limits index names to getMaxIndexNameLength()-1 plus an 'I' that is appended to the end of the given name to avoid SQL keyword conflicts.
protected  void setupSQLTypeMap(SQLTypeMap map)
          This is the most commonly overridden method when porting to a new database.
 String stringToSQL(String string)
          PostgreSQL seems to use '\' as a quote character as well as '.
 boolean supportsAutoIncrement()
          Returns true if this dictionary / database combination supports auto-incrementing primary-key columns.
 SQLBuffer toSelect(String[] cols, String[] tables, SQLBuffer where, SQLBuffer order, boolean distinct, boolean update)
          Appends the given pieces using standard SQL.
 
Methods inherited from class com.solarmetric.kodo.impl.jdbc.schema.dict.AbstractDictionary
addForUpdateClause, bigDecimalFromSQL, bigDecimalToPreparedParameter, bigDecimalToSQL, bigIntegerFromSQL, bigIntegerToPreparedParameter, bigIntegerToSQL, blobToPreparedParameter, blobToSQL, booleanFromSQL, booleanToSQL, byteFromSQL, byteToPreparedParameter, byteToSQL, charFromSQL, charToSQL, clobFromSQL, clobToSQL, colsToString, createdSQLExecutionManager, dateToPreparedParameter, dateToTimestamp, deserialize, deserialize, doubleFromSQL, doubleToPreparedParameter, doubleToSQL, dropTableDropsIndices, floatFromSQL, floatToPreparedParameter, floatToSQL, fromSQL, getClassMappingCandidateClasses, getColumns, getCreateIndexSQL, getCreateTableSQL, getCreateTableSuffix, getDBMetaData, getDropIndexSQL, getDropTableSQL, getFieldMappingCandidateClasses, getMaxColumnNameLength, getMaxIndexNameLength, getMaxTableNameLength, getNameTruncationVersion, getNonSQL92LeftOuterJoin, getPrimaryKeyClause, getQuoteNumbers, getSchemaName, getSimulateLocking, getSQLTypeMap, getStoreCharsAsStrings, getStoreLargeNumbersAsStrings, getSupportedResultSetType, getTables, getValidateConnections, getValidateConnectionSQL, getValidColumnName, getValidTableName, initTypeMap, intFromSQL, intToPreparedParameter, intToSQL, isClosed, localeFromSQL, localeToPreparedParameter, localeToSQL, longFromSQL, longToPreparedParameter, longToSQL, objectFromSQL, objectToPreparedParameter, objectToSQL, prepareLargeNumberAsString, prepareStatement, serialize, setColumnNameGenerator, setCreateTableSuffix, setDBMetaData, setIndexNameGenerator, setMaxColumnNameLength, setMaxIndexNameLength, setMaxTableNameLength, setNameTruncationVersion, setNullParameter, setQuoteNumbers, setSchemaName, setSimulateLocking, setStoreCharsAsStrings, setStoreLargeNumbersAsStrings, setTableNameGenerator, setTransactionIsolation, setValidateConnections, setValidateConnectionSQL, shortFromSQL, shortToPreparedParameter, shortToSQL, stringFromSQL, stringToPreparedParameter, supportsLocking, supportsNonSQL92LeftOuterJoins, supportsUpdateCountsForBatch, tablesToString, timestampFromSQL, toPreparedParameter, toSelect, toSelect, toSQL, truncate, truncate, validateConfiguration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PostgresDictionary

public PostgresDictionary()
Method Detail

static void ()

getPlatform

public String getPlatform()
Description copied from class: AbstractDictionary
Return the title of this database platform, used for display only.
Overrides:
getPlatform in class AbstractDictionary

stringToSQL

public String stringToSQL(String string)
PostgreSQL seems to use '\' as a quote character as well as '.
Overrides:
stringToSQL in class AbstractDictionary

clobToPreparedParameter

public void clobToPreparedParameter(PreparedStatement st,
                                    int index,
                                    Object val)
                             throws SQLException
Overrides:
clobToPreparedParameter in class AbstractDictionary

characterToPreparedParameter

public void characterToPreparedParameter(PreparedStatement st,
                                         int index,
                                         Character val)
                                  throws SQLException
Overrides:
characterToPreparedParameter in class AbstractDictionary

dateToSQL

public Object dateToSQL(Date val)
Description copied from interface: DBDictionary
Convert data into SQL for the current database platform.
Overrides:
dateToSQL in class AbstractDictionary

setupSQLTypeMap

protected void setupSQLTypeMap(SQLTypeMap map)
Description copied from class: AbstractDictionary
This is the most commonly overridden method when porting to a new database. Most databases have different mappings between java and SQL types; this method can be used to setup the mappings for the database being ported.
Overrides:
setupSQLTypeMap in class AbstractDictionary

getDropColumnSQL

public SQLBuffer[] getDropColumnSQL(Column column)
PostgreSQL can't deal with dropping columns.
Overrides:
getDropColumnSQL in class AbstractDictionary

getAddColumnSQL

public SQLBuffer[] getAddColumnSQL(Column column)
PostgreSQL has special needs when altering PK columns.
Overrides:
getAddColumnSQL in class AbstractDictionary

getColumnDeclaration

protected SQLBuffer getColumnDeclaration(Column column,
                                         boolean ignorePK)
This method can be overridden if the database does not support standard column declarations, which are in the form: <column-name> <sql-type> [NOT NULL]. Where NOT NULL is appended if it is a primary key column.

toSelect

public SQLBuffer toSelect(String[] cols,
                          String[] tables,
                          SQLBuffer where,
                          SQLBuffer order,
                          boolean distinct,
                          boolean update)
Description copied from class: AbstractDictionary
Appends the given pieces using standard SQL.
Overrides:
toSelect in class AbstractDictionary
Following copied from interface: com.solarmetric.kodo.impl.jdbc.schema.DBDictionary
Parameters:
cols - list of values the columns to select
tables - list of the tables to select from
where - the WHERE conditions; may be null if none
order - the ORDER BY conditions; may be null if none
distinct - if true, this should be a SELECT DISTINCT-equivalent query
update - if true this should be a SELECT FOR UPDATE-equivalent query

blobFromSQL

public Object blobFromSQL(ResultSet rs,
                          int column)
                   throws SQLException
Description copied from interface: DBDictionary
Convert the specified column of the SQL ResultSet to the proper java type.
Overrides:
blobFromSQL in class AbstractDictionary

dateFromSQL

public Date dateFromSQL(ResultSet rs,
                        int column)
                 throws SQLException
Description copied from interface: DBDictionary
Convert the specified column of the SQL ResultSet to the proper java type.
Overrides:
dateFromSQL in class AbstractDictionary

getDatePrecision

protected int getDatePrecision()
Description copied from class: AbstractDictionary
Return the precision to which dates are stored in this type of data store. Returns MILLI by default, as java.util.Date is only precise to the nearest millisecond. This value is used when generating timestamps to store in the data store. It is important that we never generate SQL data with greater precision than what will be returned to us, as otherwise we can get into awkward situations in which we cannot use retrieved values in where clauses since the data is not sufficiently precise. SQLServer behaves strangely here. It returns values whose millis are not accurate, but allows SELECT, DELETE statements using these non-accurate milli values. It must perform some internal rounding. Oracle, MySQL return values precise to the second on select, but will select/delete all values in a particular second, not just those values with exactly 0 nanos.
Overrides:
getDatePrecision in class AbstractDictionary

getValidIndexName

public String getValidIndexName(String name)
Limits index names to getMaxIndexNameLength()-1 plus an 'I' that is appended to the end of the given name to avoid SQL keyword conflicts.
Overrides:
getValidIndexName in class AbstractDictionary

booleanToPreparedParameter

public void booleanToPreparedParameter(PreparedStatement st,
                                       int index,
                                       Boolean val)
                                throws SQLException
Overrides:
booleanToPreparedParameter in class AbstractDictionary

supportsAutoIncrement

public boolean supportsAutoIncrement()
Description copied from interface: DBDictionary
Returns true if this dictionary / database combination supports auto-incrementing primary-key columns.
Overrides:
supportsAutoIncrement in class AbstractDictionary

getNextAutoIncrementValue

public long getNextAutoIncrementValue(Table table,
                                      SQLExecutionManager sqlem)
                               throws SQLException
Description copied from interface: DBDictionary
Returns the next auto-increment value for a given table.
Overrides:
getNextAutoIncrementValue in class AbstractDictionary

getColumnDeclaration

protected SQLBuffer getColumnDeclaration(Column column)
Description copied from class: AbstractDictionary
This method can be overridden if the database does not support standard column declarations, which are in the form: <column-name> <sql-type> [NOT NULL]. Where NOT NULL is appended if it is a primary key column.
Overrides:
getColumnDeclaration in class AbstractDictionary

getAutoIncrementSequence

protected String getAutoIncrementSequence(Column col)
Returns the auto-increment sequence name created by Postgres for col.

SolarMetric Kodo JDO 2.5.8 generated on January 11 2004

Copyright 2001,2002,2003 SolarMetric, Inc. All Rights Reserved.