Class JDBCMapper
java.lang.Object
org.nuxeo.ecm.core.storage.sql.jdbc.JDBCConnection
org.nuxeo.ecm.core.storage.sql.jdbc.JDBCRowMapper
org.nuxeo.ecm.core.storage.sql.jdbc.JDBCMapper
A
JDBCMapper
maps objects to and from a JDBC database. It is specific to a given database connection, as it
computes statements.
The JDBCMapper
does the mapping according to the policy defined by a Model
, and generates SQL
statements recorded in the SQLInfo
.
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static interface
protected class
Nested classes/interfaces inherited from interface org.nuxeo.ecm.core.storage.sql.Mapper
Mapper.Identification
Nested classes/interfaces inherited from interface org.nuxeo.ecm.core.storage.sql.RowMapper
RowMapper.CopyResult, RowMapper.IdWithTypes, RowMapper.NodeInfo, RowMapper.RowBatch, RowMapper.RowUpdate
-
Field Summary
Modifier and TypeFieldDescriptionprotected static Map<String,
JDBCMapper.CursorResult> protected static final String
Fields inherited from class org.nuxeo.ecm.core.storage.sql.jdbc.JDBCRowMapper
COLLECTION_DELETE_BEFORE_APPEND_PROP, DEBUG_MAX_TREE, UPDATE_BATCH_SIZE
Fields inherited from class org.nuxeo.ecm.core.storage.sql.jdbc.JDBCConnection
connection, countExecutes, dialect, executeCount, logger, model, setClientInfo, sqlInfo, supportsBatchUpdates
Fields inherited from interface org.nuxeo.ecm.core.storage.sql.Mapper
CLOSE, GET_IDENTIFICATION
-
Constructor Summary
ConstructorDescriptionJDBCMapper
(Model model, Session.PathResolver pathResolver, SQLInfo sqlInfo, VCSClusterInvalidator clusterInvalidator, RepositoryImpl repository) Creates a new Mapper. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
void
close()
protected String
computeDistinctDocuments
(String query, boolean distinctDocuments) void
createClusterNode
(Serializable nodeId) Informs the cluster that this node exists.protected ScrollResult<String>
defaultScroll
(String query) protected void
deleteClusterInvals
(Serializable nodeId) protected QueryMaker
findQueryMaker
(String queryType) Gets the ids for all the ancestors of the given row ids.protected Set<Serializable>
Uses iterative parentid selection.getClusterInvalidations
(Serializable nodeId) Gets the invalidations from other cluster nodes.int
Gets the root id for a given repository, if registered.int
getTableSize
(String tableName) void
insertClusterInvalidations
(Serializable nodeId, VCSInvalidations invalidations) Inserts the invalidation rows for the other cluster nodes.protected static String
join
(Collection<String> strings, char sep) void
markReferencedBlobs
(BiConsumer<String, String> markerCallback) Marks the blobs in use by passing them to the provided callback (taking the blob key and the repository name).protected void
prepareUserReadAcls
(QueryFilter queryFilter) query
(String query, String queryType, QueryFilter queryFilter, boolean countTotal) Makes a NXQL query to the database.query
(String query, String queryType, QueryFilter queryFilter, long countUpTo) Makes a NXQL query to the database.queryAndFetch
(String query, String queryType, QueryFilter queryFilter, boolean distinctDocuments, Object... params) Makes a query to the database and returns an iterable (which must be closed when done).queryProjection
(String query, String queryType, QueryFilter queryFilter, boolean distinctDocuments, long countUpTo, Object... params) Makes a query to the database.protected <T> PartialList<T>
queryProjection
(String query, String queryType, QueryFilter queryFilter, long countUpTo, JDBCMapper.BiFunctionSQLException<SQLInfo.SQLInfoSelect, ResultSet, T> extractor, Object... params) void
protected void
registerCursor
(String scrollId, PreparedStatement ps, ResultSet rs, int batchSize, int keepAliveSeconds) void
removeClusterNode
(Serializable nodeId) Removes this node from the cluster.Get the next batch of results containing id of documents, thescrollId
is part of the previousScrollResult
response.Executes the given query and returns the first batch of results containing id of documents, next batch must be requested within thekeepAliveSeconds
delay.scroll
(String query, QueryFilter queryFilter, int batchSize, int keepAliveSeconds) Executes the given query and returns the first batch of results containing id of documents, next batch must be requested within thekeepAliveSeconds
delay.protected ScrollResult<String>
scrollSearch
(String query, QueryFilter queryFilter, int batchSize, int keepAliveSeconds) void
setRootId
(Serializable repositoryId, Serializable id) Records the newly generated root id for a given repository.int
setToPreparedStatement
(PreparedStatement ps, int i, Serializable object) protected boolean
unregisterCursor
(String scrollId) void
Methods inherited from class org.nuxeo.ecm.core.storage.sql.jdbc.JDBCRowMapper
cleanupDeletedRows, clearCache, copy, copyHier, copyHierRecursive, copyRows, deleteRows, deleteRowsDirect, deleteRowsSoft, doSoftDeleteRows, generateNewId, getBinaryFulltext, getCacheSize, getChildrenIdsWithTypes, getChildrenNodeInfos, getCollectionIO, getDescendantsInfo, getDescendantsInfoIterative, getNodeInfo, getSelectRows, insertCollectionRows, insertSimpleRows, newIdArray, read, readCollectionArrays, readCollectionRowArray, readSelectionRows, readSelectionsIds, readSimpleRow, readSimpleRows, receiveInvalidations, remove, rollback, sendInvalidations, setToPreparedStatementIdArray, updateCollectionRows, updateSimpleRows, updateSimpleRowWithValues, write, writeCreates, writeDeletes, writeUpdates
Methods inherited from class org.nuxeo.ecm.core.storage.sql.jdbc.JDBCConnection
checkConcurrentUpdate, closeConnection, connect, countExecute, getDataSourceName, getIdentification, getRepositoryName
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.nuxeo.ecm.core.storage.sql.Mapper
cleanupDeletedRows, getIdentification
Methods inherited from interface org.nuxeo.ecm.core.storage.sql.RowMapper
clearCache, copy, copy, generateNewId, getBinaryFulltext, getCacheSize, getDescendantsInfo, read, readCollectionRowArray, readSelectionRows, readSelectionsIds, readSimpleRow, receiveInvalidations, remove, rollback, sendInvalidations, write
-
Field Details
-
cursorResults
-
NOSCROLL_ID
- See Also:
-
-
Constructor Details
-
JDBCMapper
public JDBCMapper(Model model, Session.PathResolver pathResolver, SQLInfo sqlInfo, VCSClusterInvalidator clusterInvalidator, RepositoryImpl repository) Creates a new Mapper.- Parameters:
model
- the modelpathResolver
- the path resolver (used for startswith queries)sqlInfo
- the sql infoclusterInvalidator
- the cluster invalidatorrepository
- the repository
-
-
Method Details
-
close
public void close() -
getTableSize
- Specified by:
getTableSize
in interfaceMapper
-
getClusterNodeIdType
public int getClusterNodeIdType()- Specified by:
getClusterNodeIdType
in interfaceMapper
-
createClusterNode
Description copied from interface:Mapper
Informs the cluster that this node exists.- Specified by:
createClusterNode
in interfaceMapper
-
removeClusterNode
Description copied from interface:Mapper
Removes this node from the cluster.- Specified by:
removeClusterNode
in interfaceMapper
-
deleteClusterInvals
- Throws:
SQLException
-
insertClusterInvalidations
Description copied from interface:Mapper
Inserts the invalidation rows for the other cluster nodes.- Specified by:
insertClusterInvalidations
in interfaceMapper
-
join
-
getClusterInvalidations
Description copied from interface:Mapper
Gets the invalidations from other cluster nodes.- Specified by:
getClusterInvalidations
in interfaceMapper
-
getRootId
Description copied from interface:Mapper
Gets the root id for a given repository, if registered. -
setRootId
Description copied from interface:Mapper
Records the newly generated root id for a given repository. -
findQueryMaker
-
prepareUserReadAcls
-
query
public PartialList<Serializable> query(String query, String queryType, QueryFilter queryFilter, boolean countTotal) Description copied from interface:Mapper
Makes a NXQL query to the database. -
query
public PartialList<Serializable> query(String query, String queryType, QueryFilter queryFilter, long countUpTo) Description copied from interface:Mapper
Makes a NXQL query to the database.- Specified by:
query
in interfaceMapper
- Parameters:
query
- the queryqueryType
- the query typequeryFilter
- the query filtercountUpTo
- if-1
, count the total size without offset/limit.
If0
, don't count the total size.
Ifn
, count the total number if there are less than n documents otherwise set the size to-1
.- Returns:
- the list of matching document ids
-
queryAndFetch
public IterableQueryResult queryAndFetch(String query, String queryType, QueryFilter queryFilter, boolean distinctDocuments, Object... params) Description copied from interface:Mapper
Makes a query to the database and returns an iterable (which must be closed when done).- Specified by:
queryAndFetch
in interfaceMapper
- Parameters:
query
- the queryqueryType
- the query typequeryFilter
- the query filterdistinctDocuments
- iftrue
then a maximum of one row per document will be returnedparams
- optional query-type-dependent parameters- Returns:
- an iterable, which must be closed when done
-
queryProjection
public PartialList<Map<String,Serializable>> queryProjection(String query, String queryType, QueryFilter queryFilter, boolean distinctDocuments, long countUpTo, Object... params) Description copied from interface:Mapper
Makes a query to the database.- Specified by:
queryProjection
in interfaceMapper
- Parameters:
query
- the queryqueryType
- the query typequeryFilter
- the query filterdistinctDocuments
- iftrue
then a maximum of one row per document will be returnedcountUpTo
- if-1
, also count the total size without offset/limit.
If0
, don't count the total size.
Ifn
, count the total number if there are less than n documents otherwise set the size to-1
.params
- optional query-type-dependent parameters- Returns:
- a projection
-
computeDistinctDocuments
-
queryProjection
protected <T> PartialList<T> queryProjection(String query, String queryType, QueryFilter queryFilter, long countUpTo, JDBCMapper.BiFunctionSQLException<SQLInfo.SQLInfoSelect, ResultSet, T> extractor, Object... params) -
setToPreparedStatement
public int setToPreparedStatement(PreparedStatement ps, int i, Serializable object) throws SQLException - Throws:
SQLException
-
scroll
Description copied from interface:Mapper
Executes the given query and returns the first batch of results containing id of documents, next batch must be requested within thekeepAliveSeconds
delay. -
scroll
public ScrollResult<String> scroll(String query, QueryFilter queryFilter, int batchSize, int keepAliveSeconds) Description copied from interface:Mapper
Executes the given query and returns the first batch of results containing id of documents, next batch must be requested within thekeepAliveSeconds
delay. -
checkForTimedoutScroll
protected void checkForTimedoutScroll() -
scrollSearch
protected ScrollResult<String> scrollSearch(String query, QueryFilter queryFilter, int batchSize, int keepAliveSeconds) -
registerCursor
protected void registerCursor(String scrollId, PreparedStatement ps, ResultSet rs, int batchSize, int keepAliveSeconds) -
unregisterCursor
-
defaultScroll
-
scroll
Description copied from interface:Mapper
Get the next batch of results containing id of documents, thescrollId
is part of the previousScrollResult
response. -
getAncestorsIds
Description copied from interface:Mapper
Gets the ids for all the ancestors of the given row ids.- Specified by:
getAncestorsIds
in interfaceMapper
- Parameters:
ids
- the ids- Returns:
- the set of ancestor ids
-
getAncestorsIdsIterative
Uses iterative parentid selection. -
updateReadAcls
public void updateReadAcls()- Specified by:
updateReadAcls
in interfaceMapper
-
rebuildReadAcls
public void rebuildReadAcls()- Specified by:
rebuildReadAcls
in interfaceMapper
-
markReferencedBlobs
Description copied from interface:Mapper
Marks the blobs in use by passing them to the provided callback (taking the blob key and the repository name).- Specified by:
markReferencedBlobs
in interfaceMapper
-