PostgresAdapter (cayenne-doc: Cayenne Documentation 5.0-M2 API)
Description: declaration: package: org.apache.cayenne.dba.postgres, class: PostgresAdapter

# Class PostgresAdapter

java.lang.Object
org.apache.cayenne.dba.JdbcAdapter
org.apache.cayenne.dba.postgres.PostgresAdapter

All Implemented Interfaces:
  `DbAdapter`

public class PostgresAdapter extends JdbcAdapter
DbAdapter implementation for PostgreSQL RDBMS . Sample connection settings to use with PostgreSQL are shown below:

         postgres.jdbc.username = test
         postgres.jdbc.password = secret
         postgres.jdbc.url = jdbc:postgresql://serverhostname/cayenne
         postgres.jdbc.driver = org.postgresql.Driver

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `BYTEA`

  ### Fields inherited from class JdbcAdapter

  `caseInsensitiveCollations, ejbqlTranslatorFactory, extendedTypes, logger, quotingStrategy, resourceLocator, supportsBatchUpdates, supportsGeneratedKeys, supportsUniqueConstraints, typesHandler`
  Modifier and Type
  Field
  Description
  `protected boolean`
  `caseInsensitiveCollations`
  `protected EJBQLTranslatorFactory`
  `ejbqlTranslatorFactory`
  `protected ExtendedTypeMap`
  `extendedTypes`
  `protected JdbcEventLogger`
  `logger`
  `protected QuotingStrategy`
  `quotingStrategy`
  `protected ResourceLocator`
  `resourceLocator`
  `protected boolean`
  `supportsBatchUpdates`
  `protected boolean`
  `supportsGeneratedKeys`
  `protected boolean`
  `supportsUniqueConstraints`
  `protected TypesHandler`
  `typesHandler`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `PostgresAdapter(RuntimeProperties runtimeProperties, List<ExtendedType> defaultExtendedTypes, List<ExtendedType> userExtendedTypes, List<ExtendedTypeFactory> extendedTypeFactories, ResourceLocator resourceLocator, ValueObjectTypeRegistry valueObjectTypeRegistry)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `bindParameter(PreparedStatement statement, ParameterBinding binding)`
  Binds an object value to PreparedStatement's parameter.
  `DbAttribute`
  `buildAttribute(String name, String typeName, int type, int size, int scale, boolean allowNulls)`
  Creates and returns a DbAttribute based on supplied parameters (usually obtained from database meta data).
  `protected void`
  `configureExtendedTypes(ExtendedTypeMap map)`
  Installs appropriate ExtendedTypes as converters for passing values between JDBC and Java layers.
  `String`
  `createTable(DbEntity ent)`
  Customizes table creating procedure for PostgreSQL.
  `Collection<String>`
  `dropTableStatements(DbEntity table)`
  Adds the CASCADE option to the DROP TABLE clause.
  `SQLAction`
  `getAction(Query query, DataNode node)`
  Uses PostgresActionBuilder to create the right action.
  `SQLTreeProcessor`
  `getSqlTreeProcessor()`
  `List<String>`
  `getSystemSchemas()`
  `boolean`
  `supportsCatalogsOnReverseEngineering()`
  Returns true.
  `boolean`
  `typeSupportsLength(int type)`
  Returns true if supplied type can have a length attribute as a part of column definition

  ### Methods inherited from class JdbcAdapter

  `createEJBQLTranslatorFactory, createFkConstraint, createQuotingStrategy, createTableAppendColumn, createTableAppendPKClause, createUniqueConstraint, externalTypesForJdbcType, findResource, getBatchTerminator, getEjbqlTranslatorFactory, getExtendedTypes, getJdbcEventLogger, getPkGenerator, getQuotingStrategy, getSelectTranslator, getSystemCatalogs, getType, initExtendedTypes, setEjbqlTranslatorFactory, setPkGenerator, setSupportsBatchUpdates, setSupportsGeneratedKeys, setSupportsUniqueConstraints, sizeAndPrecision, supportsBatchUpdates, supportsGeneratedKeys, supportsUniqueConstraints, tableTypeForTable, tableTypeForView, typeSupportsScale, unwrap`
  Modifier and Type
  Method
  Description
  `protected EJBQLTranslatorFactory`
  `createEJBQLTranslatorFactory()`
  Creates and returns an `EJBQLTranslatorFactory` used to generate visitors for EJBQL to SQL translations.
  `String`
  `createFkConstraint(DbRelationship rel)`
  Returns a SQL string that can be used to create a foreign key constraint for the relationship.
  `protected QuotingStrategy`
  `createQuotingStrategy()`
  `void`
  `createTableAppendColumn(StringBuffer sqlBuffer, DbAttribute column)`
  Appends SQL for column creation to CREATE TABLE buffer.
  `protected void`
  `createTableAppendPKClause(StringBuffer sqlBuffer, DbEntity entity)`
  `String`
  `createUniqueConstraint(DbEntity source, Collection<DbAttribute> columns)`
  Returns a DDL string to create a unique constraint over a set of columns.
  `String[]`
  `externalTypesForJdbcType(int type)`
  Returns an array of RDBMS types that can be used with JDBC `type`.
  `protected URL`
  `findResource(String name)`
  Locates and returns a named adapter resource.
  `String`
  `getBatchTerminator()`
  Returns default separator - a semicolon.
  `EJBQLTranslatorFactory`
  `getEjbqlTranslatorFactory()`
  Returns a translator factory for EJBQL to SQL translation.
  `ExtendedTypeMap`
  `getExtendedTypes()`
  Returns a map of ExtendedTypes that is used to translate values between Java and JDBC layer.
  `JdbcEventLogger`
  `getJdbcEventLogger()`
  `PkGenerator`
  `getPkGenerator()`
  Returns primary key generator associated with this DbAdapter.
  `QuotingStrategy`
  `getQuotingStrategy()`
  Returns SQL identifier quoting strategy object
  `SelectTranslator`
  `getSelectTranslator(FluentSelect<?,?> query, EntityResolver entityResolver)`
  `List<String>`
  `getSystemCatalogs()`
  `static String`
  `getType(DbAdapter adapter, DbAttribute column)`
  `protected void`
  `initExtendedTypes(List<ExtendedType> defaultExtendedTypes, List<ExtendedType> userExtendedTypes, List<ExtendedTypeFactory> extendedTypeFactories, ValueObjectTypeRegistry valueObjectTypeRegistry)`
  `void`
  `setEjbqlTranslatorFactory(EJBQLTranslatorFactory ejbqlTranslatorFactory)`
  Sets a translator factory for EJBQL to SQL translation.
  `void`
  `setPkGenerator(PkGenerator pkGenerator)`
  Sets new primary key generator.
  `void`
  `setSupportsBatchUpdates(boolean flag)`
  `void`
  `setSupportsGeneratedKeys(boolean flag)`
  `void`
  `setSupportsUniqueConstraints(boolean flag)`
  `static String`
  `sizeAndPrecision(DbAdapter adapter, DbAttribute column)`
  `boolean`
  `supportsBatchUpdates()`
  Returns `true` if the target database supports batch updates.
  `boolean`
  `supportsGeneratedKeys()`
  Returns true if a target database supports key autogeneration.
  `boolean`
  `supportsUniqueConstraints()`
  Returns true.
  `String`
  `tableTypeForTable()`
  Returns the name of the table type (as returned by `DatabaseMetaData.getTableTypes`) for a simple user table.
  `String`
  `tableTypeForView()`
  Returns the name of the table type (as returned by `DatabaseMetaData.getTableTypes`) for a view table.
  `boolean`
  `typeSupportsScale(int type)`
  Returns true if supplied type can have a scale attribute as a part of column definition.
  `DbAdapter`
  `unwrap()`
  Simply returns this, as JdbcAdapter is not a wrapper.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface DbAdapter

  `supportsGeneratedKeysForBatchInserts`
  Modifier and Type
  Method
  Description
  `default boolean`
  `supportsGeneratedKeysForBatchInserts()`
  Returns true if a target database supports key autogeneration in a batch insert.

- ## Field Details

  - ### BYTEA

    public static final String BYTEA
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### PostgresAdapter

    public PostgresAdapter(RuntimeProperties runtimeProperties, List<ExtendedType> defaultExtendedTypes, List<ExtendedType> userExtendedTypes, List<ExtendedTypeFactory> extendedTypeFactories, ResourceLocator resourceLocator, ValueObjectTypeRegistry valueObjectTypeRegistry)

- ## Method Details

  - ### getSqlTreeProcessor

    public SQLTreeProcessor getSqlTreeProcessor()
    Specified by:
      `getSqlTreeProcessor` in interface `DbAdapter`
    Overrides:
      `getSqlTreeProcessor` in class `JdbcAdapter`
    Returns:
      `SQLTreeProcessor` that can adjust SQL tree to specific database flavour
    Since:
      4.2

  - ### getAction

    public SQLAction getAction(Query query, DataNode node)
    Uses PostgresActionBuilder to create the right action.
    Specified by:
      `getAction` in interface `DbAdapter`
    Overrides:
      `getAction` in class `JdbcAdapter`
    Since:
      1.2

  - ### configureExtendedTypes

    protected void configureExtendedTypes(ExtendedTypeMap map)
    Installs appropriate ExtendedTypes as converters for passing values between JDBC and Java layers.
    Overrides:
      `configureExtendedTypes` in class `JdbcAdapter`

  - ### buildAttribute

    public DbAttribute buildAttribute(String name, String typeName, int type, int size, int scale, boolean allowNulls)
    Description copied from interface: `DbAdapter`
    Creates and returns a DbAttribute based on supplied parameters (usually obtained from database meta data).
    Specified by:
      `buildAttribute` in interface `DbAdapter`
    Overrides:
      `buildAttribute` in class `JdbcAdapter`
    Parameters:
      `name` - database column name
      `typeName` - database specific type name, may be used as a hint to determine the right JDBC type.
      `type` - JDBC column type
      `size` - database column size (ignored if less than zero)
      `scale` - database column scale, i.e. the number of decimal digits (ignored if less than zero)
      `allowNulls` - database column nullable parameter

  - ### bindParameter

    public void bindParameter(PreparedStatement statement, ParameterBinding binding) throws SQLException, Exception
    Description copied from interface: `DbAdapter`
    Binds an object value to PreparedStatement's parameter.
    Specified by:
      `bindParameter` in interface `DbAdapter`
    Overrides:
      `bindParameter` in class `JdbcAdapter`
    Throws:
      `SQLException`
      `Exception`

  - ### createTable

    public String createTable(DbEntity ent)
    Customizes table creating procedure for PostgreSQL. One difference with generic implementation is that "bytea" type has no explicit length unlike similar binary types in other databases.
    Specified by:
      `createTable` in interface `DbAdapter`
    Overrides:
      `createTable` in class `JdbcAdapter`
    Since:
      1.0.2

  - ### typeSupportsLength

    public boolean typeSupportsLength(int type)
    Description copied from class: `JdbcAdapter`
    Returns true if supplied type can have a length attribute as a part of column definition
    Specified by:
      `typeSupportsLength` in interface `DbAdapter`
    Overrides:
      `typeSupportsLength` in class `JdbcAdapter`

  - ### dropTableStatements

    public Collection<String> dropTableStatements(DbEntity table)
    Adds the CASCADE option to the DROP TABLE clause.
    Specified by:
      `dropTableStatements` in interface `DbAdapter`
    Overrides:
      `dropTableStatements` in class `JdbcAdapter`

  - ### supportsCatalogsOnReverseEngineering

    public boolean supportsCatalogsOnReverseEngineering()
    Description copied from class: `JdbcAdapter`
    Returns true.
    Specified by:
      `supportsCatalogsOnReverseEngineering` in interface `DbAdapter`
    Overrides:
      `supportsCatalogsOnReverseEngineering` in class `JdbcAdapter`

  - ### getSystemSchemas

    public List<String> getSystemSchemas()
    Specified by:
      `getSystemSchemas` in interface `DbAdapter`
    Overrides:
      `getSystemSchemas` in class `JdbcAdapter`
    Returns:
      list of system schemas