Class SQLInfo
- java.lang.Object
-
- org.nuxeo.ecm.core.storage.sql.jdbc.SQLInfo
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SQLInfo.ColumnMapMaker
Builds the map from a result set given a list of columns and column keys.static interface
SQLInfo.MapMaker
Knows how to build a result map for a row given aResultSet
.static class
SQLInfo.SQLInfoSelect
class
SQLInfo.SQLInfoSelection
Info about how to do the query to get aSelection
.protected class
SQLInfo.TableMaker
-
Field Summary
Fields Modifier and Type Field Description protected List<Column>
clusterInvalidationsColumns
protected List<Column>
createClusterNodeColumns
protected String
createClusterNodeSql
Database
database
protected Column
deleteClusterInvalsColumn
protected String
deleteClusterInvalsSql
protected Column
deleteClusterNodeColumn
protected String
deleteClusterNodeSql
Dialect
dialect
protected List<Column>
getBinariesColumns
protected List<String>
getBinariesSql
boolean
proxiesEnabled
Map<String,SQLInfo.SQLInfoSelect>
selectFragmentById
boolean
softDeleteEnabled
protected Map<String,List<SQLStatement>>
sqlStatements
Map<String,Serializable>
sqlStatementsProperties
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
executeSQLStatements(String category, String ddlMode, Connection connection, JDBCLogger logger, SQLStatement.ListCollector ddlCollector)
Executes the SQL statements for the given category.List<Column>
getClusterInvalidationsColumns()
int
getClusterNodeIdType()
SQLInfo.SQLInfoSelect
getCopyHier(boolean explicitName, boolean resetVersion)
Column
getCopyIdColumn(String tableName)
String
getCopySql(String tableName)
List<Column>
getCreateClusterNodeColumns()
String
getCreateClusterNodeSql()
Database
getDatabase()
Column
getDeleteClusterInvalsColumn()
String
getDeleteClusterInvalsSql()
Column
getDeleteClusterNodeColumn()
String
getDeleteClusterNodeSql()
String
getDeleteSql(String tableName)
Returns the SQLDELETE
to delete a row.String
getDeleteSql(String tableName, int n)
Returns the SQLDELETE
to delete several rows.String
getIdEqualsClause(String tableName)
Returns the clause used to match a given row by id in the given table.List<Column>
getInsertColumns(String tableName)
Returns the list of columns to use for anINSERT
statementgetInsertSql(java.lang.String)
.List<Column>
getInsertRootIdColumns()
String
getInsertRootIdSql()
String
getInsertSql(String tableName)
Returns the SQLINSERT
to add a row.int
getMaximumArgsForIn()
SQLInfo.SQLInfoSelect
getSelectAncestorsIds()
Select all ancestors ids for several fragments.String
getSelectChildrenIdsAndTypesSql(boolean excludeSpecialChildren, boolean excludeRegularChildren)
List<Column>
getSelectChildrenIdsAndTypesWhatColumns()
SQLInfo.SQLInfoSelect
getSelectChildrenNodeInfos(int nids)
Selects all children (not complex) for several parent ids.String
getSelectDescendantsInfoSql()
List<Column>
getSelectDescendantsInfoWhatColumns()
SQLInfo.SQLInfoSelect
getSelectFragmentsByIds(String tableName, int nids)
Select by ids for all values of several fragments.SQLInfo.SQLInfoSelect
getSelectFragmentsByIds(String tableName, int nids, String[] orderBys, Set<String> skipColumns)
Select by ids for all values of several fragments (maybe ordered along columns -- for collection fragments retrieval).SQLInfo.SQLInfoSelection
getSelection(SelectionType type)
SQLInfo.SQLInfoSelect
getSelectParentIds(int nids)
Select parentid by ids for all values of several fragments.String
getSelectRootIdSql()
Column
getSelectRootIdWhatColumn()
String
getSoftDeleteClause()
Returns null orAND isdeleted IS NULL
if soft delete is activated.String
getSoftDeleteClause(String tableName)
ReturnsAND isdeleted IS NULL
if this is the hierarchy table and soft delete is activated.String
getSoftDeleteCleanupSql()
Returns the SQL to clean (hard-delete) soft-deleted rows.String
getSoftDeleteSql()
Returns the SQL to soft-delete several rows.SQLInfo.SQLInfoSelect
getUpdateById(String tableName, RowMapper.RowUpdate rowu)
UPDATE tableName SET key1 = ?, key2 = ?, ...Update
getUpdateByIdForKeys(String tableName, List<String> keys)
protected void
initAncestorsSQL()
Creates the SQL for the table holding ancestors information.protected void
initClusterSQL()
protected void
initFragmentSQL(String tableName)
Creates the SQL for one fragment (simple or collection).protected void
initHierarchySQL()
Creates the SQL for the table holding hierarchy information.protected void
initRepositorySQL()
Creates the SQL for the table holding global repository information.protected void
initSelectDescendantsSQL()
protected void
initSelections()
protected void
initSQL(boolean requiresClusterSQL)
Creates all the sql from the models.void
initSQLStatements(Map<String,Serializable> testProps, List<String> sqlInitFiles)
SQLInfo.SQLInfoSelect
makeSelect(Table table, String[] orderBys, String... freeColumns)
Basic SELECT x, y, z FROM table WHERE a = ? AND b = ?SQLInfo.SQLInfoSelect
makeSelect(Table table, String from, List<String> clauses, String[] orderBys, String... freeColumns)
Same as above but the FROM can be passed in, to allow JOINs.
-
-
-
Field Detail
-
softDeleteEnabled
public final boolean softDeleteEnabled
-
proxiesEnabled
public final boolean proxiesEnabled
-
selectFragmentById
public final Map<String,SQLInfo.SQLInfoSelect> selectFragmentById
-
createClusterNodeSql
protected String createClusterNodeSql
-
createClusterNodeColumns
protected List<Column> createClusterNodeColumns
-
deleteClusterNodeSql
protected String deleteClusterNodeSql
-
deleteClusterNodeColumn
protected Column deleteClusterNodeColumn
-
deleteClusterInvalsSql
protected String deleteClusterInvalsSql
-
deleteClusterInvalsColumn
protected Column deleteClusterInvalsColumn
-
clusterInvalidationsColumns
protected List<Column> clusterInvalidationsColumns
-
sqlStatements
protected Map<String,List<SQLStatement>> sqlStatements
-
sqlStatementsProperties
public Map<String,Serializable> sqlStatementsProperties
-
getBinariesSql
protected List<String> getBinariesSql
-
getBinariesColumns
protected List<Column> getBinariesColumns
-
-
Method Detail
-
getDatabase
public Database getDatabase()
-
getSelectRootIdSql
public String getSelectRootIdSql()
-
getSelectRootIdWhatColumn
public Column getSelectRootIdWhatColumn()
-
getInsertRootIdSql
public String getInsertRootIdSql()
-
getInsertRootIdColumns
public List<Column> getInsertRootIdColumns()
-
getSelection
public SQLInfo.SQLInfoSelection getSelection(SelectionType type)
-
getSelectChildrenIdsAndTypesSql
public String getSelectChildrenIdsAndTypesSql(boolean excludeSpecialChildren, boolean excludeRegularChildren)
-
getSelectChildrenIdsAndTypesWhatColumns
public List<Column> getSelectChildrenIdsAndTypesWhatColumns()
-
getSelectDescendantsInfoSql
public String getSelectDescendantsInfoSql()
-
getSelectDescendantsInfoWhatColumns
public List<Column> getSelectDescendantsInfoWhatColumns()
-
getCreateClusterNodeSql
public String getCreateClusterNodeSql()
-
getCreateClusterNodeColumns
public List<Column> getCreateClusterNodeColumns()
-
getDeleteClusterNodeSql
public String getDeleteClusterNodeSql()
-
getDeleteClusterNodeColumn
public Column getDeleteClusterNodeColumn()
-
getDeleteClusterInvalsSql
public String getDeleteClusterInvalsSql()
-
getDeleteClusterInvalsColumn
public Column getDeleteClusterInvalsColumn()
-
getClusterNodeIdType
public int getClusterNodeIdType()
-
getClusterInvalidationsColumns
public List<Column> getClusterInvalidationsColumns()
-
getInsertSql
public String getInsertSql(String tableName)
Returns the SQLINSERT
to add a row. The columns that represent sequences that are implicitly auto-incremented aren't included.- Parameters:
tableName
- the table name- Returns:
- the SQL
INSERT
statement
-
getInsertColumns
public List<Column> getInsertColumns(String tableName)
Returns the list of columns to use for anINSERT
statementgetInsertSql(java.lang.String)
.- Parameters:
tableName
- the table name- Returns:
- the list of columns
-
getIdEqualsClause
public String getIdEqualsClause(String tableName)
Returns the clause used to match a given row by id in the given table.Takes into account soft deletes.
- Parameters:
tableName
- the table name- Returns:
- the clause, like
table.id = ?
-
getSoftDeleteClause
public String getSoftDeleteClause(String tableName)
ReturnsAND isdeleted IS NULL
if this is the hierarchy table and soft delete is activated.- Parameters:
tableName
- the table name- Returns:
- the clause
-
getSoftDeleteClause
public String getSoftDeleteClause()
Returns null orAND isdeleted IS NULL
if soft delete is activated.- Returns:
- the clause, or null
-
getUpdateById
public SQLInfo.SQLInfoSelect getUpdateById(String tableName, RowMapper.RowUpdate rowu)
UPDATE tableName SET key1 = ?, key2 = ?, ... WHERE id = ? AND condition1 = ? AND condition2 IS NULL ...
-
getUpdateByIdForKeys
public Update getUpdateByIdForKeys(String tableName, List<String> keys)
-
getSelectFragmentsByIds
public SQLInfo.SQLInfoSelect getSelectFragmentsByIds(String tableName, int nids)
Select by ids for all values of several fragments.
-
getSelectFragmentsByIds
public SQLInfo.SQLInfoSelect getSelectFragmentsByIds(String tableName, int nids, String[] orderBys, Set<String> skipColumns)
Select by ids for all values of several fragments (maybe ordered along columns -- for collection fragments retrieval).
-
getSelectAncestorsIds
public SQLInfo.SQLInfoSelect getSelectAncestorsIds()
Select all ancestors ids for several fragments.Fast alternative to the slowest iterative
getSelectParentIds(int)
.- Returns:
- null if it's not possible in one call in this dialect
-
getSelectParentIds
public SQLInfo.SQLInfoSelect getSelectParentIds(int nids)
Select parentid by ids for all values of several fragments.
-
getSelectChildrenNodeInfos
public SQLInfo.SQLInfoSelect getSelectChildrenNodeInfos(int nids)
Selects all children (not complex) for several parent ids.
-
getDeleteSql
public String getDeleteSql(String tableName)
Returns the SQLDELETE
to delete a row. The primary key columns are free parameters.- Parameters:
tableName
- the table name- Returns:
- the SQL
DELETE
statement
-
getDeleteSql
public String getDeleteSql(String tableName, int n)
Returns the SQLDELETE
to delete several rows. The primary key columns are free parameters.- Parameters:
tableName
- the table namen
- the number of rows to delete- Returns:
- the SQL
DELETE
statement with aIN
for the keys
-
getSoftDeleteSql
public String getSoftDeleteSql()
Returns the SQL to soft-delete several rows. The array of ids and the time are free parameters.- Returns:
- the SQL statement
-
getSoftDeleteCleanupSql
public String getSoftDeleteCleanupSql()
Returns the SQL to clean (hard-delete) soft-deleted rows. The max and beforeTime are free parameters.- Returns:
- the SQL statement
-
getCopyHier
public SQLInfo.SQLInfoSelect getCopyHier(boolean explicitName, boolean resetVersion)
-
getCopySql
public String getCopySql(String tableName)
-
getCopyIdColumn
public Column getCopyIdColumn(String tableName)
-
initSQL
protected void initSQL(boolean requiresClusterSQL)
Creates all the sql from the models.
-
initClusterSQL
protected void initClusterSQL()
-
initRepositorySQL
protected void initRepositorySQL()
Creates the SQL for the table holding global repository information. This includes the id of the hierarchy root node.
-
initHierarchySQL
protected void initHierarchySQL()
Creates the SQL for the table holding hierarchy information.
-
initSelectDescendantsSQL
protected void initSelectDescendantsSQL()
-
initAncestorsSQL
protected void initAncestorsSQL()
Creates the SQL for the table holding ancestors information.This table holds trigger-updated information extracted from the recursive parent-child relationship in the hierarchy table.
-
initFragmentSQL
protected void initFragmentSQL(String tableName)
Creates the SQL for one fragment (simple or collection).
-
initSelections
protected void initSelections()
-
makeSelect
public SQLInfo.SQLInfoSelect makeSelect(Table table, String[] orderBys, String... freeColumns)
Basic SELECT x, y, z FROM table WHERE a = ? AND b = ?with optional ORDER BY x, y DESC
-
makeSelect
public SQLInfo.SQLInfoSelect makeSelect(Table table, String from, List<String> clauses, String[] orderBys, String... freeColumns)
Same as above but the FROM can be passed in, to allow JOINs.
-
initSQLStatements
public void initSQLStatements(Map<String,Serializable> testProps, List<String> sqlInitFiles) throws IOException
- Throws:
IOException
-
executeSQLStatements
public void executeSQLStatements(String category, String ddlMode, Connection connection, JDBCLogger logger, SQLStatement.ListCollector ddlCollector) throws SQLException
Executes the SQL statements for the given category.- Throws:
SQLException
-
getMaximumArgsForIn
public int getMaximumArgsForIn()
-
-