public class H2Engine extends AbstractDatabaseEngine
| Modifier and Type | Field and Description |
|---|---|
static String |
CONSTRAINT_NAME_ALREADY_EXISTS
Constraint name already exists.
|
protected static String |
H2_DRIVER
The PostgreSQL JDBC driver.
|
static QueryExceptionHandler |
H2_QUERY_EXCEPTION_HANDLER
An instance of
QueryExceptionHandler specific for H2 engine, to be used in disambiguating SQL exceptions. |
static String |
INDEX_ALREADY_EXISTS
Name is already used by an existing index.
|
static String |
NAME_ALREADY_EXISTS
Name is already used by an existing object.
|
static String |
OPTIONAL_FEATURE_NOT_SUPPORTED
An optional feature is not implemented by the driver or not supported by the DB.
|
static String |
TABLE_CAN_ONLY_HAVE_ONE_PRIMARY_KEY
Table can have only one primary key.
|
static String |
TABLE_OR_VIEW_DOES_NOT_EXIST
Table or view does not exist.
|
conn, currentSchema, DEFAULT_QUERY_EXCEPTION_HANDLER, dev, dialect, eh, entities, injector, logger, notificationLogger, properties, socketTimeoutExecutor, stmts, translator| Constructor and Description |
|---|
H2Engine(PdbProperties properties)
Creates a new PostgreSql connection.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addColumn(DbEntity entity,
DbColumn... columns)
Adds the column to an existent table.
|
protected void |
addFks(DbEntity entity,
Set<DbFk> fks)
Adds foreign key constraints to the table in the database that the provided entity represents.
|
protected void |
addIndexes(DbEntity entity)
Add the desired indexes.
|
protected void |
addPrimaryKey(DbEntity entity)
Add a primary key to the entity.
|
protected void |
addSequences(DbEntity entity)
Adds the necessary sequences.
|
protected MappedEntity |
createPreparedStatementForInserts(DbEntity entity)
Creates and gets the prepared statement that will be used for insertions.
|
protected ResultIterator |
createResultIterator(PreparedStatement ps)
Creates a specific
ResultIterator for the engine in place given a prepared statement. |
protected ResultIterator |
createResultIterator(Statement statement,
String sql)
Creates a specific
ResultIterator given the engine implementation. |
protected void |
createTable(DbEntity entity)
Creates the table.
|
protected long |
doPersist(PreparedStatement ps,
MappedEntity me,
boolean useAutoInc,
int lastBindPosition)
DB engine specific auxiliary method for
AbstractDatabaseEngine.persist(String, EntityEntry, boolean) to effectively perform
the persist action. |
protected void |
dropColumn(DbEntity entity,
String... columns)
Drops the column.
|
protected void |
dropSequences(DbEntity entity)
Drops the sequences of the entity.
|
protected void |
dropTable(DbEntity entity)
Drops the table.
|
protected int |
entityToPreparedStatement(DbEntity entity,
PreparedStatement ps,
EntityEntry entry,
boolean useAutoInc)
Translates the given entry entity to the prepared statement.
|
protected String |
getFinalJdbcConnection(String jdbc)
Gets the final JDBC connection.
|
protected PreparedStatement |
getPreparedStatementForPersist(boolean useAutoInc,
MappedEntity mappedEntity)
Gets the
PreparedStatement to use in a persist operation, depending on whether autoInc is to be used or not. |
protected QueryExceptionHandler |
getQueryExceptionHandler()
Gets the instance of
QueryExceptionHandler to be used in disambiguating SQL exceptions. |
String |
getSchema()
Gets the schema being used in the current
connection. |
Class<? extends AbstractTranslator> |
getTranslatorClass()
Gets the class that translates SQL bound to this engine.
|
boolean |
isStringAggDistinctCapable()
Checks if the engine supports using DISTINCT inside a string aggregation.
|
protected void |
setSchema(String schema)
Sets the schema for the current
connection. |
addBatch, addEntity, addFks, beginTransaction, checkConnection, checkConnection, checkConnection, clearParameters, close, commentCharacter, commit, connect, containsEntity, createBatch, createBatch, createBatch, createBatch, createBatch, createPreparedStatement, createPreparedStatement, createPreparedStatement, createPreparedStatement, createSelectStatement, dropEntity, dropEntity, dropFkQuery, dropFks, dropFks, dropView, duplicate, entityToPreparedStatementForBatch, escapeCharacter, executePS, executePSUpdate, executeUpdate, executeUpdate, executeUpdateSilently, flush, getConnection, getDBProperties, getDialect, getEntities, getEntities, getImportedKeys, getMetadata, getMetadata, getPrivateKey, getProperties, getPSIterator, getPSIterator, getPSResultSet, getQueryMetadata, getQueryMetadata, handleOperation, hasIdentityColumn, inject, isTransactionActive, iterator, iterator, iterator, iterator, iterator, iterator, loadEntity, objectToArray, persist, persist, preparedStatementExists, processResultIterator, query, query, query, query, reconnectExceptionally, removeEntity, removePreparedStatement, rollback, setExceptionHandler, setParameter, setParameter, setParameters, setParameterValues, setTransactionIsolation, toPdbType, translate, translateType, updateEntityprotected static final String H2_DRIVER
public static final String NAME_ALREADY_EXISTS
public static final String INDEX_ALREADY_EXISTS
public static final String TABLE_CAN_ONLY_HAVE_ONE_PRIMARY_KEY
public static final String TABLE_OR_VIEW_DOES_NOT_EXIST
public static final String CONSTRAINT_NAME_ALREADY_EXISTS
public static final String OPTIONAL_FEATURE_NOT_SUPPORTED
public static final QueryExceptionHandler H2_QUERY_EXCEPTION_HANDLER
QueryExceptionHandler specific for H2 engine, to be used in disambiguating SQL exceptions.public H2Engine(PdbProperties properties) throws DatabaseEngineException
properties - The properties for the database connection.DatabaseEngineException - When the connection fails.protected String getFinalJdbcConnection(String jdbc)
AbstractDatabaseEngineImplementations might override this method in order to change the JDBC connection.
getFinalJdbcConnection in class AbstractDatabaseEnginejdbc - The current JDBC connection.public Class<? extends AbstractTranslator> getTranslatorClass()
AbstractDatabaseEnginegetTranslatorClass in class AbstractDatabaseEngineprotected int entityToPreparedStatement(DbEntity entity, PreparedStatement ps, EntityEntry entry, boolean useAutoInc) throws DatabaseEngineException
AbstractDatabaseEngineentityToPreparedStatement in class AbstractDatabaseEngineentity - The entity.ps - The prepared statement.entry - The entry.DatabaseEngineException - if something occurs during the translation.protected void createTable(DbEntity entity) throws DatabaseEngineException
AbstractDatabaseEnginecreateTable in class AbstractDatabaseEngineentity - The entity.DatabaseEngineException - If something goes wrong while creating the table.protected void addPrimaryKey(DbEntity entity) throws DatabaseEngineException
AbstractDatabaseEngineaddPrimaryKey in class AbstractDatabaseEngineentity - The entity.DatabaseEngineException - If something goes wrong while creating the table.protected void addIndexes(DbEntity entity) throws DatabaseEngineException
AbstractDatabaseEngineaddIndexes in class AbstractDatabaseEngineentity - The entity.DatabaseEngineException - If something goes wrong while creating the table.protected void addSequences(DbEntity entity) throws DatabaseEngineException
AbstractDatabaseEngineaddSequences in class AbstractDatabaseEngineentity - The entity.DatabaseEngineException - If something goes wrong while creating the table.protected MappedEntity createPreparedStatementForInserts(DbEntity entity) throws DatabaseEngineException
AbstractDatabaseEnginecreatePreparedStatementForInserts in class AbstractDatabaseEngineentity - The entity.DatabaseEngineException - If something goes wrong while creating the table.protected void dropSequences(DbEntity entity) throws DatabaseEngineException
AbstractDatabaseEnginedropSequences in class AbstractDatabaseEngineentity - The entity.DatabaseEngineException - If something goes wrong dropping the sequences.protected void dropTable(DbEntity entity) throws DatabaseEngineException
AbstractDatabaseEnginedropTable in class AbstractDatabaseEngineentity - The entity.DatabaseEngineException - If something goes wrong dropping the sequences.protected void dropColumn(DbEntity entity, String... columns) throws DatabaseEngineException
AbstractDatabaseEnginedropColumn in class AbstractDatabaseEngineentity - The entity.columns - The column name to drop.DatabaseEngineException - If something goes wrong dropping the sequences.protected void addColumn(DbEntity entity, DbColumn... columns) throws DatabaseEngineException
AbstractDatabaseEngineaddColumn in class AbstractDatabaseEngineentity - The entity that represents the table.columns - The db column to add.DatabaseEngineException - If something goes wrong adding columns.protected PreparedStatement getPreparedStatementForPersist(boolean useAutoInc, MappedEntity mappedEntity)
AbstractDatabaseEnginePreparedStatement to use in a persist operation, depending on whether autoInc is to be used or not.getPreparedStatementForPersist in class AbstractDatabaseEngineuseAutoInc - Whether to use autoInc.mappedEntity - The mapped entity for which to get the prepared statement.PreparedStatement.protected long doPersist(PreparedStatement ps, MappedEntity me, boolean useAutoInc, int lastBindPosition) throws Exception
AbstractDatabaseEngineAbstractDatabaseEngine.persist(String, EntityEntry, boolean) to effectively perform
the persist action.doPersist in class AbstractDatabaseEngineps - The PreparedStatement to use in the persist operationme - The mapped entity on which to persist.useAutoInc - Whether to use autoInc.lastBindPosition - The position (1-based) of the last bind parameter that was filled in the prepared statement.0 if there's no auto generated value). If the table has more
than 1 column with auto generated values, then it will return the first column found.Exception - if any problem occurs while persisting.public boolean isStringAggDistinctCapable()
DatabaseEngineprotected void addFks(DbEntity entity, Set<DbFk> fks) throws DatabaseEngineException
AbstractDatabaseEngineaddFks in class AbstractDatabaseEngineentity - The entity.fks - The foreign keys to be added.DatabaseEngineException - If something goes wrong creating the FKs.public String getSchema() throws DatabaseEngineException
AbstractDatabaseEngineconnection.getSchema in class AbstractDatabaseEnginenull if there is none.DatabaseEngineException - If a database access error occurs or this method is called on a closed connection.protected void setSchema(String schema) throws DatabaseEngineException
AbstractDatabaseEngineconnection.setSchema in class AbstractDatabaseEngineDatabaseEngineException - If schema doesn't exist, a database access error occurs or this method
is called on a closed connection.protected ResultIterator createResultIterator(Statement statement, String sql) throws DatabaseEngineException
AbstractDatabaseEngineResultIterator given the engine implementation.createResultIterator in class AbstractDatabaseEnginestatement - The statement.sql - The SQL sentence.DatabaseEngineException - If a database access error occurs.protected ResultIterator createResultIterator(PreparedStatement ps) throws DatabaseEngineException
AbstractDatabaseEngineResultIterator for the engine in place given a prepared statement.createResultIterator in class AbstractDatabaseEngineps - The prepared statement.DatabaseEngineException - If a database access error occurs.protected QueryExceptionHandler getQueryExceptionHandler()
AbstractDatabaseEngineQueryExceptionHandler to be used in disambiguating SQL exceptions.getQueryExceptionHandler in class AbstractDatabaseEngineQueryExceptionHandler.Copyright © 2021 Feedzai. All rights reserved.