Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.core.storage.sql.jdbc
Class SQLInfo

java.lang.Object
  extended by org.nuxeo.ecm.core.storage.sql.jdbc.SQLInfo

public class SQLInfo
extends Object

This singleton generates and holds the actual SQL DDL and DML statements for the operations needed by the Mapper, given a Model.

It is specific to one SQL dialect.


Nested Class Summary
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 a ResultSet.
static class SQLInfo.SQLInfoSelect
           
 class SQLInfo.SQLInfoSelection
          Info about how to do the query to get a SQLInfo.SQLInfoSelection.
 
Field Summary
 Database database
           
 Dialect dialect
           
 
Constructor Summary
SQLInfo(Model model, Dialect dialect)
          Generates and holds the needed SQL statements given a Model and a Dialect.
 
Method Summary
 void executeSQLStatements(String category, JDBCConnection jdbc)
          Executes the SQL statements for the given category.
 List<Column> getClusterInvalidationsColumns()
           
 List<Column> getCopyHierColumns(boolean explicitName, boolean createVersion)
           
 String getCopyHierSql(boolean explicitName, boolean createVersion)
           
 Column getCopyHierWhereColumn()
           
 Column getCopyIdColumn(String tableName)
           
 String getCopySql(String tableName)
           
 Database getDatabase()
           
 String getDeleteSql(String tableName)
          Returns the SQL DELETE to delete a row.
 String getDeleteSql(String tableName, int n)
          Returns the SQL DELETE to delete several rows.
 List<Column> getInsertColumns(String tableName)
          Returns the list of columns to use for an statement getInsertSql(java.lang.String).
 List<Column> getInsertRootIdColumns()
           
 String getInsertRootIdSql()
           
 String getInsertSql(String tableName)
          Returns the SQL INSERT to add a row.
 int getMaximumArgsForIn()
           
 SQLInfo.SQLInfoSelect getSelectAncestorsIds()
          Select all ancestors ids for several fragments.
 String getSelectChildrenIdsAndTypesSql(boolean onlyComplex)
           
 List<Column> getSelectChildrenIdsAndTypesWhatColumns()
           
 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()
           
 SQLInfo.SQLInfoSelect getUpdateById(String tableName, Collection<String> keys)
           
 Update getUpdateByIdForKeys(String tableName, List<String> keys)
           
 void initSQLStatements(Map<String,Serializable> testProps)
           
static SQLInfo.SQLInfoSelect makeSelect(Table table, String[] orderBys, String... freeColumns)
          Basic SELECT x, y, z FROM table WHERE a = ? AND b = ?
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

database

public final Database database

dialect

public final Dialect dialect
Constructor Detail

SQLInfo

public SQLInfo(Model model,
               Dialect dialect)
        throws StorageException
Generates and holds the needed SQL statements given a Model and a Dialect.

Parameters:
model - the model
dialect - the SQL dialect
Throws:
StorageException
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 onlyComplex)

getSelectChildrenIdsAndTypesWhatColumns

public List<Column> getSelectChildrenIdsAndTypesWhatColumns()

getSelectDescendantsInfoSql

public String getSelectDescendantsInfoSql()

getSelectDescendantsInfoWhatColumns

public List<Column> getSelectDescendantsInfoWhatColumns()

getClusterInvalidationsColumns

public List<Column> getClusterInvalidationsColumns()

getInsertSql

public String getInsertSql(String tableName)
Returns the SQL INSERT 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 an statement getInsertSql(java.lang.String).

Parameters:
tableName - the table name
Returns:
the list of columns

getUpdateById

public SQLInfo.SQLInfoSelect getUpdateById(String tableName,
                                           Collection<String> keys)

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.


getDeleteSql

public String getDeleteSql(String tableName)
Returns the SQL DELETE 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 SQL DELETE to delete several rows. The primary key columns are free parameters.

Parameters:
tableName - the table name
n - the number of rows to delete
Returns:
the SQL DELETE statement with a IN for the keys

getCopyHierSql

public String getCopyHierSql(boolean explicitName,
                             boolean createVersion)

getCopyHierColumns

public List<Column> getCopyHierColumns(boolean explicitName,
                                       boolean createVersion)

getCopyHierWhereColumn

public Column getCopyHierWhereColumn()

getCopySql

public String getCopySql(String tableName)

getCopyIdColumn

public Column getCopyIdColumn(String tableName)

makeSelect

public static 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


initSQLStatements

public void initSQLStatements(Map<String,Serializable> testProps)
                       throws IOException
Throws:
IOException

executeSQLStatements

public void executeSQLStatements(String category,
                                 JDBCConnection jdbc)
                          throws SQLException
Executes the SQL statements for the given category.

Throws:
SQLException

getMaximumArgsForIn

public int getMaximumArgsForIn()

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.