public class OracleEngine extends AbstractDatabaseEngine
| Modifier and Type | Class and Description |
|---|---|
static interface |
OracleEngine.Action0
Represents an action that can throw any exception.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
FOREIGN_ALREADY_EXISTS
Foreign key already exists
|
static String |
NAME_ALREADY_EXISTS
Name is already used by an existing object.
|
protected static String |
ORACLE_DRIVER
The Oracle JDBC driver.
|
static QueryExceptionHandler |
ORACLE_QUERY_EXCEPTION_HANDLER
An instance of
QueryExceptionHandler specific for Oracle engine, to be used in disambiguating SQL exceptions. |
static String |
SEQUENCE_DOES_NOT_EXIST
Sequence does not exist.
|
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 |
|---|
OracleEngine(PdbProperties properties)
Creates a new Oracle 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 void |
connect()
Connects to the database.
|
void |
createPreparedStatement(String name,
Expression query)
Creates a prepared statement.
|
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.
|
void |
flush()
Flushes the batches for all the registered entities.
|
protected Properties |
getDBProperties()
Get the properties to be passed to the database connection that will be created.
|
protected ResultSet |
getImportedKeys(String entityName)
Gets a description of the columns that are referenced by the given table's foreign key columns.
|
Map<String,DbColumnType> |
getMetadata(String schemaPattern,
String tableNamePattern)
Gets the table metadata (table must be in the current schema).
|
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. |
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.
|
void |
setParameter(String name,
int index,
Object param)
Sets the parameter on the specified index.
|
void |
setParameters(String name,
Object... params)
Sets the parameters on the specified prepared statement.
|
protected void |
setParameterValues(PreparedStatement ps,
int index,
Object param)
Sets the value of a parameter in
index to the value provided in param. |
protected void |
setPreparedStatementValue(PreparedStatement ps,
int index,
DbColumn dbColumn,
Object value,
boolean fromBatch)
Sets a value in the prepared statement.
|
protected void |
setTransactionIsolation()
Overrides
AbstractDatabaseEngine.setTransactionIsolation() This is because
Oracle does not support READ_UNCOMMITTED e REPEATABLE_READ. |
addBatch, addEntity, addFks, beginTransaction, checkConnection, checkConnection, checkConnection, clearParameters, close, commentCharacter, commit, containsEntity, createBatch, createBatch, createBatch, createBatch, createBatch, createBatch, createPreparedStatement, createPreparedStatement, createPreparedStatement, createSelectStatement, dropEntity, dropEntity, dropFkQuery, dropFks, dropFks, dropView, duplicate, entityToPreparedStatement, entityToPreparedStatementForBatch, entityToPreparedStatementInternal, escapeCharacter, executePS, executePSUpdate, executeUpdate, executeUpdate, executeUpdateSilently, getConnection, getDialect, getEntities, getEntities, getFinalJdbcConnection, getMetadata, getPrivateKey, getProperties, getPSIterator, getPSIterator, getPSResultSet, getQueryMetadata, getQueryMetadata, getSchema, handleOperation, hasIdentityColumn, inject, isTransactionActive, iterator, iterator, iterator, iterator, iterator, iterator, loadEntity, objectToArray, onConnectionCreated, persist, persist, preparedStatementExists, processResultIterator, query, query, query, query, reconnectExceptionally, removeEntity, removePreparedStatement, rollback, setExceptionHandler, setParameter, setSchema, toPdbType, translate, translateType, updateEntityprotected static final String ORACLE_DRIVER
public static final String NAME_ALREADY_EXISTS
public static final String TABLE_CAN_ONLY_HAVE_ONE_PRIMARY_KEY
public static final String SEQUENCE_DOES_NOT_EXIST
public static final String TABLE_OR_VIEW_DOES_NOT_EXIST
public static final String FOREIGN_ALREADY_EXISTS
public static final QueryExceptionHandler ORACLE_QUERY_EXCEPTION_HANDLER
QueryExceptionHandler specific for Oracle engine, to be used in disambiguating SQL exceptions.public OracleEngine(PdbProperties properties) throws DatabaseEngineException
properties - The properties for the database connection.DatabaseEngineException - When the connection fails.protected Properties getDBProperties()
AbstractDatabaseEngineAbstractDatabaseEngine
implementation to specify them. This is used, for instance, to set the database connection timeout.getDBProperties in class AbstractDatabaseEngineprotected void connect()
throws Exception
AbstractDatabaseEngineconnect in class AbstractDatabaseEngineException - If connection is not possible, or failed to decrypt username/password if encryption was provided.public void setParameters(String name, Object... params) throws DatabaseEngineException, ConnectionResetException
DatabaseEnginesetParameters in interface DatabaseEnginesetParameters in class AbstractDatabaseEnginename - The prepared statement name.params - The parameters to set.DatabaseEngineException - If something occurs setting the parameters.ConnectionResetException - If the connection was reset while trying to set parameters.public void setParameter(String name, int index, Object param) throws DatabaseEngineException, ConnectionResetException
DatabaseEnginesetParameter in interface DatabaseEnginesetParameter in class AbstractDatabaseEnginename - The prepared statement name.index - The index to set.param - The parameter to set.DatabaseEngineException - If something occurs setting the parameters.ConnectionResetException - If the connection was reset while trying to set the parameter.public boolean isStringAggDistinctCapable()
DatabaseEnginepublic void flush()
throws DatabaseEngineException
AbstractDatabaseEngineflush in interface DatabaseEngineflush in class AbstractDatabaseEngineDatabaseEngineException - If something goes wrong while persisting data.protected void setPreparedStatementValue(PreparedStatement ps, int index, DbColumn dbColumn, Object value, boolean fromBatch) throws Exception
AbstractDatabaseEnginesetPreparedStatementValue in class AbstractDatabaseEngineps - The prepared statement.index - The index of the value to set in the prepared statement.dbColumn - The DbColumn for which to set the value in the prepared statement.value - The value to set.fromBatch - Whether this translation is to be done in the context of a batch update.Exception - If something wrong occurs setting the value.protected void setParameterValues(PreparedStatement ps, int index, Object param) throws SQLException
AbstractDatabaseEngineindex to the value provided in param.setParameterValues in class AbstractDatabaseEngineps - The PreparedStatement to insert the association between index and the param.index - The index to set the value to.param - The value to be set at the provided index.SQLException - If something goes wrong accessing the database.protected void setTransactionIsolation()
throws SQLException
AbstractDatabaseEngine.setTransactionIsolation() This is because
Oracle does not support READ_UNCOMMITTED e REPEATABLE_READ.setTransactionIsolation in class AbstractDatabaseEngineSQLException - If a database access error occurs.public Class<? extends AbstractTranslator> getTranslatorClass()
AbstractDatabaseEnginegetTranslatorClass in class AbstractDatabaseEngineprotected 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.public void createPreparedStatement(String name, Expression query) throws NameAlreadyExistsException, DatabaseEngineException
DatabaseEnginecreatePreparedStatement in interface DatabaseEnginecreatePreparedStatement in class AbstractDatabaseEnginename - The prepared statement name.query - The query.NameAlreadyExistsException - If the name already exists.DatabaseEngineException - If something goes wrong creating the statement.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.protected 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.protected ResultSet getImportedKeys(String entityName) throws SQLException
AbstractDatabaseEnginegetImportedKeys in class AbstractDatabaseEngineentityName - The entity name.ResultSet containing information about columns referenced by a foreign key.SQLException - If a database access error occurs when getting key information.public Map<String,DbColumnType> getMetadata(String schemaPattern, String tableNamePattern) throws DatabaseEngineException
DatabaseEnginegetMetadata in interface DatabaseEnginegetMetadata in class AbstractDatabaseEngineschemaPattern - A schema name pattern; must match the schema name as it is stored in the database;
"" retrieves those without a schema; null means that the schema name
should not be used to narrow the search.tableNamePattern - A table name pattern; must match the table name as it is stored in the database.DatabaseEngineException - If something occurs getting the metadata.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 © 2023 Feedzai. All rights reserved.