com.j256.ormlite.db
Class PostgresDatabaseType

java.lang.Object
  extended by com.j256.ormlite.db.BaseDatabaseType
      extended by com.j256.ormlite.db.PostgresDatabaseType
All Implemented Interfaces:
DatabaseType

public class PostgresDatabaseType
extends BaseDatabaseType
implements DatabaseType

Postgres database type information used to create the tables, etc..

Author:
graywatson

Nested Class Summary
 
Nested classes/interfaces inherited from class com.j256.ormlite.db.BaseDatabaseType
BaseDatabaseType.BooleanNumberFieldConverter
 
Field Summary
 
Fields inherited from class com.j256.ormlite.db.BaseDatabaseType
booleanConverter
 
Constructor Summary
PostgresDatabaseType()
           
 
Method Summary
protected  void appendByteType(StringBuilder sb)
          Output the SQL type for a Java byte.
 void appendEscapedEntityName(StringBuilder sb, String word)
          Add a entity-name word to the string builder wrapped in the proper characters to escape it.
 void appendEscapedWordEntityName(StringBuilder sb, String word)
           
protected  void appendObjectType(StringBuilder sb)
          Output the SQL type for a Java object.
 void appendSelectNextValFromSequence(StringBuilder sb, String sequenceName)
          Append the SQL necessary to get the next-value from a sequence.
protected  void configureGeneratedIdSequence(StringBuilder sb, FieldType fieldType, List<String> statementsBefore, List<String> additionalArgs, List<String> queriesAfter)
          Output the SQL necessary to configure a generated-id column.
 void dropColumnArg(FieldType fieldType, List<String> statementsBefore, List<String> statementsAfter)
          Takes a FieldType and adds the necessary statements to the before and after lists necessary so that the dropping of the table will succeed and will clear other associated sequences or other database artifacts
 String getDriverClassName()
          Return the class name of the database driver.
 String getDriverUrlPart()
          Return the part in the database URI which identifies the particular database.
 boolean isIdSequenceNeeded()
          Return true if the database needs a sequence when you use generated IDs.
 
Methods inherited from class com.j256.ormlite.db.BaseDatabaseType
appendBooleanType, appendCanBeNull, appendColumnArg, appendCreateTableSuffix, appendDateType, appendDefaultValue, appendDoubleType, appendEnumIntType, appendEnumStringType, appendEscapedWord, appendFloatType, appendIntegerType, appendLimitValue, appendLongType, appendShortType, appendStringType, buildDatabaseAccess, configureGeneratedId, configureId, convertColumnName, generateIdSequenceName, getCommentLinePrefix, getDefaultVarcharWidth, getFieldConverter, isCreateTableReturnsZero, isEntityNamesMustBeUpCase, isLimitAfterSelect, isLimitSqlSupported, isVarcharFieldWidthSupported, loadDriver
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.j256.ormlite.db.DatabaseType
appendColumnArg, appendCreateTableSuffix, appendEscapedWord, appendLimitValue, buildDatabaseAccess, convertColumnName, generateIdSequenceName, getCommentLinePrefix, getFieldConverter, isCreateTableReturnsZero, isEntityNamesMustBeUpCase, isLimitAfterSelect, isLimitSqlSupported, isVarcharFieldWidthSupported, loadDriver
 

Constructor Detail

PostgresDatabaseType

public PostgresDatabaseType()
Method Detail

getDriverUrlPart

public String getDriverUrlPart()
Description copied from interface: DatabaseType
Return the part in the database URI which identifies the particular database. Usually the URI is in the form jdbc:ddd:... where ddd is the driver url part.

Specified by:
getDriverUrlPart in interface DatabaseType

getDriverClassName

public String getDriverClassName()
Description copied from interface: DatabaseType
Return the class name of the database driver.

Specified by:
getDriverClassName in interface DatabaseType

appendByteType

protected void appendByteType(StringBuilder sb)
Description copied from class: BaseDatabaseType
Output the SQL type for a Java byte.

Overrides:
appendByteType in class BaseDatabaseType

appendObjectType

protected void appendObjectType(StringBuilder sb)
Description copied from class: BaseDatabaseType
Output the SQL type for a Java object.

Overrides:
appendObjectType in class BaseDatabaseType

configureGeneratedIdSequence

protected void configureGeneratedIdSequence(StringBuilder sb,
                                            FieldType fieldType,
                                            List<String> statementsBefore,
                                            List<String> additionalArgs,
                                            List<String> queriesAfter)
Description copied from class: BaseDatabaseType
Output the SQL necessary to configure a generated-id column. This may add to the before statements list or additional arguments later. NOTE: Only one of configureGeneratedIdSequence, configureGeneratedId, or configureId will be called.

Overrides:
configureGeneratedIdSequence in class BaseDatabaseType

dropColumnArg

public void dropColumnArg(FieldType fieldType,
                          List<String> statementsBefore,
                          List<String> statementsAfter)
Description copied from interface: DatabaseType
Takes a FieldType and adds the necessary statements to the before and after lists necessary so that the dropping of the table will succeed and will clear other associated sequences or other database artifacts

Specified by:
dropColumnArg in interface DatabaseType
Overrides:
dropColumnArg in class BaseDatabaseType

appendEscapedEntityName

public void appendEscapedEntityName(StringBuilder sb,
                                    String word)
Description copied from interface: DatabaseType
Add a entity-name word to the string builder wrapped in the proper characters to escape it. This avoids problems with table, column, and sequence-names being reserved words.

Specified by:
appendEscapedEntityName in interface DatabaseType
Overrides:
appendEscapedEntityName in class BaseDatabaseType

appendEscapedWordEntityName

public void appendEscapedWordEntityName(StringBuilder sb,
                                        String word)

isIdSequenceNeeded

public boolean isIdSequenceNeeded()
Description copied from interface: DatabaseType
Return true if the database needs a sequence when you use generated IDs. Some databases (H2, MySQL) create them auto-magically. This also means that the database needs to query for a sequence value before the object is inserted. For old[er] versions of Postgres, for example, the JDBC call-back stuff to get the just-inserted id value does not work so we have to get the next sequence value by hand, assign it into the object, and then insert the object -- yes two SQL statements.

Specified by:
isIdSequenceNeeded in interface DatabaseType
Overrides:
isIdSequenceNeeded in class BaseDatabaseType

appendSelectNextValFromSequence

public void appendSelectNextValFromSequence(StringBuilder sb,
                                            String sequenceName)
Description copied from interface: DatabaseType
Append the SQL necessary to get the next-value from a sequence. This is only necessary if DatabaseType.isIdSequenceNeeded() is true.

Specified by:
appendSelectNextValFromSequence in interface DatabaseType
Overrides:
appendSelectNextValFromSequence in class BaseDatabaseType


Copyright © 2010. All Rights Reserved.