Package org.apache.cayenne.dba.postgres
Class PostgresAdapter
java.lang.Object
org.apache.cayenne.dba.JdbcAdapter
org.apache.cayenne.dba.postgres.PostgresAdapter
- All Implemented Interfaces:
DbAdapter
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 inherited from class org.apache.cayenne.dba.JdbcAdapter
batchQueryBuilderFactory, caseInsensitiveCollations, ejbqlTranslatorFactory, extendedTypes, logger, quotingStrategy, resourceLocator, supportsBatchUpdates, supportsGeneratedKeys, supportsUniqueConstraints, typesHandler
-
Constructor Summary
ConstructorDescriptionPostgresAdapter
(RuntimeProperties runtimeProperties, List<ExtendedType> defaultExtendedTypes, List<ExtendedType> userExtendedTypes, List<ExtendedTypeFactory> extendedTypeFactories, ResourceLocator resourceLocator, ValueObjectTypeRegistry valueObjectTypeRegistry) -
Method Summary
Modifier and TypeMethodDescriptionvoid
bindParameter
(PreparedStatement statement, ParameterBinding binding) Binds an object value to PreparedStatement's parameter.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
Installs appropriate ExtendedTypes as converters for passing values between JDBC and Java layers.protected PkGenerator
Creates and returns a primary key generator.createTable
(DbEntity ent) Customizes table creating procedure for PostgreSQL.dropTableStatements
(DbEntity table) Adds the CASCADE option to the DROP TABLE clause.Uses PostgresActionBuilder to create the right action.boolean
Returns true.boolean
typeSupportsLength
(int type) Returns true if supplied type can have a length attribute as a part of column definitionMethods inherited from class org.apache.cayenne.dba.JdbcAdapter
createEJBQLTranslatorFactory, createFkConstraint, createQuotingStrategy, createTableAppendColumn, createTableAppendPKClause, createUniqueConstraint, externalTypesForJdbcType, findResource, getBatchTerminator, getEjbqlTranslatorFactory, getExtendedTypes, getJdbcEventLogger, getPkGenerator, getQuotingStrategy, getSelectTranslator, getSelectTranslator, getSystemCatalogs, getType, initExtendedTypes, setEjbqlTranslatorFactory, setPkGenerator, setSupportsBatchUpdates, setSupportsGeneratedKeys, setSupportsUniqueConstraints, sizeAndPrecision, supportsBatchUpdates, supportsGeneratedKeys, supportsUniqueConstraints, tableTypeForTable, tableTypeForView, unwrap
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.cayenne.dba.DbAdapter
supportsGeneratedKeysForBatchInserts
-
Field Details
-
BYTEA
- See Also:
-
-
Constructor Details
-
PostgresAdapter
public PostgresAdapter(RuntimeProperties runtimeProperties, List<ExtendedType> defaultExtendedTypes, List<ExtendedType> userExtendedTypes, List<ExtendedTypeFactory> extendedTypeFactories, ResourceLocator resourceLocator, ValueObjectTypeRegistry valueObjectTypeRegistry)
-
-
Method Details
-
getSqlTreeProcessor
- Specified by:
getSqlTreeProcessor
in interfaceDbAdapter
- Overrides:
getSqlTreeProcessor
in classJdbcAdapter
- Returns:
SQLTreeProcessor
that can adjust SQL tree to specific database flavour- Since:
- 4.2
-
getAction
Uses PostgresActionBuilder to create the right action.- Specified by:
getAction
in interfaceDbAdapter
- Overrides:
getAction
in classJdbcAdapter
- Since:
- 1.2
-
configureExtendedTypes
Installs appropriate ExtendedTypes as converters for passing values between JDBC and Java layers.- Overrides:
configureExtendedTypes
in classJdbcAdapter
-
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 interfaceDbAdapter
- Overrides:
buildAttribute
in classJdbcAdapter
- Parameters:
name
- database column nametypeName
- database specific type name, may be used as a hint to determine the right JDBC type.type
- JDBC column typesize
- 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 interfaceDbAdapter
- Overrides:
bindParameter
in classJdbcAdapter
- Throws:
SQLException
Exception
-
createTable
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 interfaceDbAdapter
- Overrides:
createTable
in classJdbcAdapter
- 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 interfaceDbAdapter
- Overrides:
typeSupportsLength
in classJdbcAdapter
-
dropTableStatements
Adds the CASCADE option to the DROP TABLE clause.- Specified by:
dropTableStatements
in interfaceDbAdapter
- Overrides:
dropTableStatements
in classJdbcAdapter
-
createPkGenerator
Description copied from class:JdbcAdapter
Creates and returns a primary key generator. This factory method should be overriden by JdbcAdapter subclasses to provide custom implementations of PKGenerator.- Overrides:
createPkGenerator
in classJdbcAdapter
- See Also:
-
supportsCatalogsOnReverseEngineering
public boolean supportsCatalogsOnReverseEngineering()Description copied from class:JdbcAdapter
Returns true.- Specified by:
supportsCatalogsOnReverseEngineering
in interfaceDbAdapter
- Overrides:
supportsCatalogsOnReverseEngineering
in classJdbcAdapter
-
getSystemSchemas
- Specified by:
getSystemSchemas
in interfaceDbAdapter
- Overrides:
getSystemSchemas
in classJdbcAdapter
- Returns:
- list of system schemas
-