public abstract class DBAdaptor extends Object implements QueryBuildingHelper, StaticDataAdaptor
Modifier and Type | Method and Description |
---|---|
void |
alterSequence(Connection conn,
SequenceElement s)
Alters sequence in the database.
|
int |
compareStrings(String left,
String right)
Compare strings using database according to current collation rules.
|
void |
createColumn(Connection conn,
Column<?> c)
Adds a new column to the table.
|
void |
createFK(Connection conn,
ForeignKey fk)
Creates a foreign key in the DB.
|
void |
createIndex(Connection conn,
Index index)
Creates a table index in the DB.
|
void |
createParameterizedView(Connection conn,
ParameterizedView pv) |
void |
createPK(Connection conn,
TableElement t)
Creates primary key on a table.
|
void |
createSchemaIfNotExists(String name)
Creates DB schema with the specified name if such didn't exist before.
|
void |
createSequence(Connection conn,
SequenceElement s)
Creates a sequence in the database.
|
void |
createSysObjects(Connection conn,
String sysSchemaName)
Creates or recreates other system objects (stored procedures, functions)
needed for Celesta functioning on current RDBMS.
|
void |
createTable(Connection conn,
TableElement te)
Creates a table "from scratch" in the database.
|
void |
createTableTriggersForMaterializedViews(Connection conn,
BasicTable t) |
void |
createView(Connection conn,
View v)
Creates a view in the DB based on metadata.
|
abstract PreparedStatement |
deleteRecordSetStatement(Connection conn,
TableElement t,
String where)
Creates a PreparedStatement object for a DELETE statement for deleting a set of records that
satisfy a condition.
|
void |
dropFK(Connection conn,
String schemaName,
String tableName,
String fkName)
Drops a foreign key from the database.
|
void |
dropIndex(Grain g,
DbIndexInfo dBIndexInfo)
Removes table index in the grain.
|
void |
dropParameterizedView(Connection conn,
String schemaName,
String viewName)
Drops parameterized view from the database.
|
void |
dropPk(Connection conn,
TableElement t,
String pkName)
Drops primary key from the table by using known name of the primary key.
|
void |
dropSequence(Connection conn,
SequenceElement s)
Drops sequence from the database.
|
void |
dropTable(Connection conn,
TableElement t)
Deletes table from RDBMS.
|
void |
dropTableTriggersForMaterializedViews(Connection conn,
BasicTable t) |
void |
dropTrigger(Connection conn,
TriggerQuery query)
Drops a trigger from DB.
|
void |
dropView(Connection conn,
String schemaName,
String viewName)
Drops view.
|
void |
executeNative(Connection conn,
String sql) |
String |
getCallFunctionSql(ParameterizedView pv)
Prepares a function call expression.
|
abstract DbColumnInfo |
getColumnInfo(Connection conn,
Column<?> c)
Returns information on a column.
|
Set<String> |
getColumns(Connection conn,
TableElement t)
Returns a set of column names for a specific table.
|
abstract int |
getCurrentIdent(Connection conn,
BasicTable t)
Returns current identity value for the table.
|
abstract int |
getDBPid(Connection conn)
Returns process id of current database connection.
|
abstract PreparedStatement |
getDeleteRecordStatement(Connection conn,
TableElement t,
String where)
Creates a PreparedStatement object for a DELETE statement for deleting a set of records that
satisfy a condition.
|
abstract List<DbFkInfo> |
getFKInfo(Connection conn,
Grain g)
Returns information on the foreign keys from grain.
|
abstract Map<String,DbIndexInfo> |
getIndices(Connection conn,
Grain g)
Returns a set of indices referring to tables specified in the indicated grain.
|
abstract PreparedStatement |
getInsertRecordStatement(Connection conn,
BasicTable t,
boolean[] nullsMask,
List<ParameterSetter> program)
Creates a PreparedStatement object for an INSERT statement to insert a record into a table.
|
abstract PreparedStatement |
getNavigationStatement(Connection conn,
FromClause from,
String orderBy,
String navigationWhereClause,
Set<String> fields,
long offset)
Returns navigable PreparedStatement by a filtered set of records.
|
abstract PreparedStatement |
getOneFieldStatement(Connection conn,
Column<?> c,
String where)
Creates a PreparedStatement object for a SELECT statement of a single column containing
at most one record.
|
abstract PreparedStatement |
getOneRecordStatement(Connection conn,
TableElement t,
String where,
Set<String> fields)
Creates a PreparedStatement object for a SELECT statement containing at most one record.
|
abstract List<String> |
getParameterizedViewList(Connection conn,
Grain g)
Get names of existing parameterized views.
|
abstract DbPkInfo |
getPKInfo(Connection conn,
TableElement t)
Returns information on the primary key of a table.
|
PreparedStatement |
getRecordSetStatement(Connection conn,
FromClause from,
String whereClause,
String orderBy,
long offset,
long rowCount,
Set<String> fields)
Returns
PreparedStatement containing a filtered set of entries. |
abstract DbSequenceInfo |
getSequenceInfo(Connection conn,
SequenceElement s)
Returns information on a sequence.
|
PreparedStatement |
getSetCountStatement(Connection conn,
FromClause from,
String whereClause)
Builds a SELECT COUNT statement.
|
Optional<String> |
getTriggerBody(Connection conn,
TriggerQuery query)
Returns body of the trigger existing in the database.
|
abstract DBType |
getType()
Returns current database type.
|
PreparedStatement |
getUpdateRecordStatement(Connection conn,
BasicTable t,
boolean[] equalsMask,
boolean[] nullsMask,
List<ParameterSetter> program,
String where)
Builds prepared statement for records UPDATE.
equalsMask[columnIndex] should contain true for the column with
index equal to columnIndex to take part in the evaluation.If nullsMask[columnIndex] contains true IS NULL check
has a priority above program[columnIndex] check - column = ? . |
List<String> |
getViewList(Connection conn,
Grain g)
Returns list of view names in the grain.
|
SQLGenerator |
getViewSQLGenerator()
Returns SQL generator for Celesta views/complex filters.
|
void |
initDataForMaterializedView(Connection conn,
MaterializedView mv)
Initializes data for a newly crated materialized view.
|
boolean |
isValidConnection(Connection conn,
int timeout)
Checking for connection validity.
|
abstract long |
nextSequenceValue(Connection conn,
SequenceElement s)
Retrieves next value from the sequence.
|
String |
pkConstraintString(TableElement tableElement)
Returns DB specific PK constraint name for a table element.
|
ZonedDateTime |
prepareZonedDateTimeForParameterSetter(Connection conn,
ZonedDateTime z) |
List<String> |
selectStaticStrings(List<String> data,
String columnName,
String orderByDirection)
Returned strings ordered by the database according to the current collation.
|
abstract boolean |
sequenceExists(Connection conn,
String schema,
String name)
Checks if sequence exists in the DB.
|
String |
sequenceString(String schemaName,
String sequenceName)
Returns template by sequence name.
|
boolean |
supportsCortegeComparing()
Whether DB supports cortege comparing.
|
abstract boolean |
tableExists(Connection conn,
String schema,
String name)
Checks if table exists in the DB.
|
String |
tableString(String schemaName,
String tableName)
Returns template by table name.
|
String |
translateDate(String date)
Translates Celesta date literal to the one from specific database.
|
abstract boolean |
triggerExists(Connection conn,
TriggerQuery query)
Checks if trigger exists in the DB.
|
void |
updateColumn(Connection conn,
Column<?> c,
DbColumnInfo actual)
Updates a table column.
|
void |
updateVersioningTrigger(Connection conn,
TableElement t) |
boolean |
userTablesExist()
Returns
true in that and only that case if DB contains user tables
(i.e. |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getInFilterClause, nullsFirst
public final void dropTable(Connection conn, TableElement t)
conn
- Connection to use.t
- TableElement metadata of deleting table provided by Celesta.public final boolean userTablesExist()
true
in that and only that case if DB contains user tables
(i.e. DB is not empty).public final void createSchemaIfNotExists(String name)
name
- schema name.public final void createColumn(Connection conn, Column<?> c)
conn
- DB connectionc
- columnpublic final PreparedStatement getUpdateRecordStatement(Connection conn, BasicTable t, boolean[] equalsMask, boolean[] nullsMask, List<ParameterSetter> program, String where)
equalsMask[columnIndex]
should contain true
for the column with
index equal to columnIndex
to take part in the evaluation.nullsMask[columnIndex]
contains true
IS NULL
check
has a priority above program[columnIndex]
check - column = ?
.conn
- DB connectiont
- updatable tableequalsMask
- equals masknullsMask
- nulls maskprogram
- collects parameter predicateswhere
- WHERE clausepublic final void createIndex(Connection conn, Index index)
conn
- DB connectionindex
- table indexpublic final void createFK(Connection conn, ForeignKey fk)
conn
- DB connectionfk
- foreign keypublic final void dropIndex(Grain g, DbIndexInfo dBIndexInfo)
g
- GraindBIndexInfo
- Information on indexpublic final PreparedStatement getRecordSetStatement(Connection conn, FromClause from, String whereClause, String orderBy, long offset, long rowCount, Set<String> fields)
PreparedStatement
containing a filtered set of entries.conn
- Connectionfrom
- Object for forming FROM part of the querywhereClause
- Where clauseorderBy
- Sort orderoffset
- Number of entries to skiprowCount
- Number of entries to return (limit filter)fields
- Requested columns. If none are provided all columns are requestedpublic final PreparedStatement getSetCountStatement(Connection conn, FromClause from, String whereClause)
conn
- Connectionfrom
- From clausewhereClause
- Where clausepublic final void dropTrigger(Connection conn, TriggerQuery query)
conn
- Connectionquery
- Trigger querypublic final void updateVersioningTrigger(Connection conn, TableElement t)
public final void createPK(Connection conn, TableElement t)
conn
- DB connectiont
- tablepublic final SQLGenerator getViewSQLGenerator()
QueryBuildingHelper
getViewSQLGenerator
in interface QueryBuildingHelper
public final void createView(Connection conn, View v)
conn
- DB connectionv
- Viewpublic final void createParameterizedView(Connection conn, ParameterizedView pv)
public final void dropTableTriggersForMaterializedViews(Connection conn, BasicTable t)
public final void createTableTriggersForMaterializedViews(Connection conn, BasicTable t)
public final void executeNative(Connection conn, String sql)
public boolean isValidConnection(Connection conn, int timeout)
conn
- connectiontimeout
- time-outtrue
if connection is valid, otherwise false
public String tableString(String schemaName, String tableName)
schemaName
- schema nametableName
- table namepublic String sequenceString(String schemaName, String sequenceName)
schemaName
- schema namesequenceName
- sequence namepublic String pkConstraintString(TableElement tableElement)
tableElement
- table elementpublic void createTable(Connection conn, TableElement te)
conn
- Connectionte
- Table for creation.
tables also in case if such table exists.public Set<String> getColumns(Connection conn, TableElement t)
conn
- DB connectiont
- Table to look the columns in.public void dropFK(Connection conn, String schemaName, String tableName, String fkName)
conn
- DB connectionschemaName
- schema nametableName
- table possessing the foreign keyfkName
- name of foreign keypublic void dropParameterizedView(Connection conn, String schemaName, String viewName)
conn
- DB connectionschemaName
- schema nameviewName
- view namepublic List<String> getViewList(Connection conn, Grain g)
conn
- DB connectiong
- Grain for which the list of view names have to be returned.public String getCallFunctionSql(ParameterizedView pv)
pv
- current parameterized viewpublic void createSequence(Connection conn, SequenceElement s)
conn
- DB connections
- sequence elementpublic void alterSequence(Connection conn, SequenceElement s)
conn
- DB connections
- sequence elementpublic void dropSequence(Connection conn, SequenceElement s)
conn
- DB connections
- sequence elementpublic void dropView(Connection conn, String schemaName, String viewName)
conn
- DB connectionschemaName
- grain nameviewName
- view namepublic void createSysObjects(Connection conn, String sysSchemaName)
conn
- DB connectionsysSchemaName
- system schema namepublic String translateDate(String date)
translateDate
in interface QueryBuildingHelper
date
- Date literalpublic Optional<String> getTriggerBody(Connection conn, TriggerQuery query)
conn
- Connectionquery
- Trigger querypublic void initDataForMaterializedView(Connection conn, MaterializedView mv)
conn
- connectionmv
- current materialized viewpublic List<String> selectStaticStrings(List<String> data, String columnName, String orderByDirection)
selectStaticStrings
in interface StaticDataAdaptor
data
- List of String to selectcolumnName
- name of result columnorderByDirection
- expression to concatenate after "ORDER BY" (ASC or DESC)public int compareStrings(String left, String right)
compareStrings
in interface StaticDataAdaptor
left
- left stringright
- right stringpublic boolean supportsCortegeComparing()
supportsCortegeComparing
in interface QueryBuildingHelper
public void dropPk(Connection conn, TableElement t, String pkName)
conn
- DB connectiont
- TablepkName
- name of the primary keypublic void updateColumn(Connection conn, Column<?> c, DbColumnInfo actual)
conn
- DB connectionc
- Column to updateactual
- Actual column infopublic ZonedDateTime prepareZonedDateTimeForParameterSetter(Connection conn, ZonedDateTime z)
prepareZonedDateTimeForParameterSetter
in interface QueryBuildingHelper
public abstract PreparedStatement getNavigationStatement(Connection conn, FromClause from, String orderBy, String navigationWhereClause, Set<String> fields, long offset)
conn
- Connectionfrom
- From clauseorderBy
- Sorting order (ascending or descending)navigationWhereClause
- Navigable set condition (from current record)fields
- Fields of selectionoffset
- First record offsetpublic abstract boolean tableExists(Connection conn, String schema, String name)
conn
- DB connectionschema
- schema namename
- table namepublic abstract boolean triggerExists(Connection conn, TriggerQuery query) throws SQLException
conn
- DB connection.query
- trigger query parametersSQLException
- thrown if resulting query failspublic abstract PreparedStatement getOneRecordStatement(Connection conn, TableElement t, String where, Set<String> fields)
conn
- DB connectiont
- tablewhere
- WHERE conditionfields
- fields of selectionpublic abstract PreparedStatement getOneFieldStatement(Connection conn, Column<?> c, String where)
conn
- DB connectionc
- column to selectwhere
- WHERE conditionpublic abstract PreparedStatement deleteRecordSetStatement(Connection conn, TableElement t, String where)
conn
- DB connectiont
- tablewhere
- conditionpublic abstract PreparedStatement getInsertRecordStatement(Connection conn, BasicTable t, boolean[] nullsMask, List<ParameterSetter> program)
conn
- DB connectiont
- tablenullsMask
- null-flags (if set the corresponding field at n-th position becomes null
)program
- collects parameters that can be set with the querypublic abstract int getCurrentIdent(Connection conn, BasicTable t)
conn
- DB connectiont
- tablepublic abstract PreparedStatement getDeleteRecordStatement(Connection conn, TableElement t, String where)
conn
- DB connectiont
- tablewhere
- condition (can be null
)public abstract DbColumnInfo getColumnInfo(Connection conn, Column<?> c)
conn
- DB connectionc
- columnpublic abstract DbPkInfo getPKInfo(Connection conn, TableElement t)
conn
- DB connectiont
- Table that the information on the primary key has to be returned frompublic abstract List<DbFkInfo> getFKInfo(Connection conn, Grain g)
conn
- DB connectiong
- grain namepublic abstract Map<String,DbIndexInfo> getIndices(Connection conn, Grain g)
conn
- DB connectiong
- Grain the tables of which have to be traversed for the indices.public abstract List<String> getParameterizedViewList(Connection conn, Grain g)
conn
- connectiong
- current grainpublic abstract int getDBPid(Connection conn)
conn
- DB connectionpublic abstract DBType getType()
public abstract long nextSequenceValue(Connection conn, SequenceElement s)
conn
- DB connections
- sequencepublic abstract boolean sequenceExists(Connection conn, String schema, String name)
conn
- DB connectionschema
- schema namename
- sequence namepublic abstract DbSequenceInfo getSequenceInfo(Connection conn, SequenceElement s)
conn
- DB connections
- sequenceCopyright © 2023 CURS. All rights reserved.