public class JDBCMapper extends JDBCRowMapper implements Mapper
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.
| Modifier and Type | Class and Description |
|---|---|
protected class |
JDBCMapper.CursorResult |
static interface |
JDBCMapper.LockCallable |
protected class |
JDBCMapper.RemoveLock |
protected class |
JDBCMapper.SetLock |
Mapper.IdentificationRowMapper.CopyResult, RowMapper.IdWithTypes, RowMapper.NodeInfo, RowMapper.RowBatch, RowMapper.RowUpdate| Modifier and Type | Field and Description |
|---|---|
protected boolean |
clusteringEnabled |
protected static Map<String,JDBCMapper.CursorResult> |
cursorResults |
protected static String |
NOSCROLL_ID |
protected TableUpgrader |
tableUpgrader |
static String |
TEST_UPGRADE |
static String |
TEST_UPGRADE_LAST_CONTRIBUTOR |
static String |
TEST_UPGRADE_LOCKS |
static String |
TEST_UPGRADE_VERSIONS |
static Map<String,Serializable> |
testProps |
COLLECTION_DELETE_BEFORE_APPEND_PROP, DEBUG_MAX_TREE, UPDATE_BATCH_SIZEconnection, countExecutes, dialect, executeCount, logger, model, noSharing, setClientInfo, sqlInfo, supportsBatchUpdates, xaresourceCLOSE, GET_IDENTIFICATIONTMENDRSCAN, TMFAIL, TMJOIN, TMNOFLAGS, TMONEPHASE, TMRESUME, TMSTARTRSCAN, TMSUCCESS, TMSUSPEND, XA_OK, XA_RDONLY| Constructor and Description |
|---|
JDBCMapper(Model model,
Session.PathResolver pathResolver,
SQLInfo sqlInfo,
ClusterInvalidator clusterInvalidator,
boolean noSharing,
RepositoryImpl repository)
Creates a new Mapper.
|
| Modifier and Type | Method and Description |
|---|---|
protected Lock |
callInTransaction(JDBCMapper.LockCallable callable,
boolean tx)
Calls the callable, inside a transaction if in cluster mode.
|
protected void |
checkForTimedoutScroll() |
void |
commit(Xid xid,
boolean onePhase) |
void |
connect() |
protected Connection |
connection(boolean autocommit) |
void |
createClusterNode(Serializable nodeId)
Informs the cluster that this node exists.
|
void |
createDatabase(String ddlMode)
Creates the necessary structures in the database.
|
protected void |
createTables(String ddlMode) |
protected ScrollResult |
defaultScroll(String query) |
protected void |
deleteClusterInvals(Serializable nodeId) |
void |
disconnect() |
void |
end(Xid xid,
int flags) |
protected QueryMaker |
findQueryMaker(String queryType) |
protected static Set<String> |
findTableNames(DatabaseMetaData metadata,
String schemaName)
Finds uppercase table names.
|
void |
forget(Xid xid) |
Set<Serializable> |
getAncestorsIds(Collection<Serializable> ids)
Gets the ids for all the ancestors of the given row ids.
|
protected Set<Serializable> |
getAncestorsIdsIterative(Collection<Serializable> ids)
Uses iterative parentid selection.
|
Invalidations |
getClusterInvalidations(Serializable nodeId)
Gets the invalidations from other cluster nodes.
|
int |
getClusterNodeIdType() |
Lock |
getLock(Serializable id)
Gets the lock state of a document.
|
Serializable |
getRootId(String repositoryId)
Gets the root id for a given repository, if registered.
|
protected String |
getTableName(String origName) |
int |
getTableSize(String tableName) |
int |
getTransactionTimeout() |
void |
insertClusterInvalidations(Serializable nodeId,
Invalidations invalidations)
Inserts the invalidation rows for the other cluster nodes.
|
boolean |
isConnected() |
boolean |
isSameRM(XAResource xares) |
protected static String |
join(Collection<String> strings,
char sep) |
void |
markReferencedBinaries()
Marks the binaries in use by passing them to the binary manager(s)'s GC mark() method.
|
int |
prepare(Xid xid) |
protected void |
prepareUserReadAcls(QueryFilter queryFilter) |
PartialList<Serializable> |
query(String query,
String queryType,
QueryFilter queryFilter,
boolean countTotal)
Makes a NXQL query to the database.
|
PartialList<Serializable> |
query(String query,
String queryType,
QueryFilter queryFilter,
long countUpTo)
Makes a NXQL query to the database.
|
IterableQueryResult |
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).
|
void |
rebuildReadAcls() |
Xid[] |
recover(int flag) |
protected void |
registerCursor(String scrollId,
PreparedStatement ps,
ResultSet rs,
int batchSize,
int keepAliveSeconds) |
void |
removeClusterNode(Serializable nodeId)
Removes this node from the cluster.
|
Lock |
removeLock(Serializable id,
String owner,
boolean force)
Removes a lock from a document.
|
ScrollResult |
scroll(String scrollId)
Get the next batch of result, the
scrollId is part of the previous ScrollResult response. |
ScrollResult |
scroll(String query,
int batchSize,
int keepAliveSeconds)
Executes the given query and returns the first batch of results, next batch must be requested
within the
keepAliveSeconds delay. |
protected ScrollResult |
scrollSearch(String query,
int batchSize,
int keepAliveSeconds) |
Lock |
setLock(Serializable id,
Lock lock)
Sets a lock on a document.
|
void |
setRootId(Serializable repositoryId,
Serializable id)
Records the newly generated root id for a given repository.
|
int |
setToPreparedStatement(PreparedStatement ps,
int i,
Serializable object) |
boolean |
setTransactionTimeout(int seconds) |
void |
start(Xid xid,
int flags) |
protected static String |
systemToString(Object o) |
protected boolean |
unregisterCursor(String scrollId) |
void |
updateReadAcls() |
protected void |
upgradeTable(String tableKey,
List<Column> addedColumns,
String ddlMode,
SQLStatement.ListCollector ddlCollector) |
cleanupDeletedRows, clearCache, copy, copyHier, copyHierRecursive, copyRows, deleteRows, deleteRowsDirect, deleteRowsSoft, doSoftDeleteRows, generateNewId, getBinaryFulltext, getCacheSize, getChildrenIdsWithTypes, getChildrenNodeInfos, getCollectionIO, getDescendantsInfo, getDescendantsInfoIterative, getSelectRows, insertCollectionRows, insertSimpleRows, newIdArray, read, readCollectionArrays, readCollectionRowArray, readSelectionRows, readSimpleRow, readSimpleRows, receiveInvalidations, remove, rollback, sendInvalidations, setToPreparedStatementIdArray, updateCollectionRows, updateSimpleRows, updateSimpleRowWithValues, write, writeCreates, writeDeletes, writeUpdatescheckConcurrentUpdate, close, closeConnections, closeStatement, closeStatement, countExecute, getDataSourceName, getIdentification, getRepositoryName, openBaseConnection, openConnectionsclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcleanupDeletedRows, close, getIdentificationclearCache, copy, generateNewId, getBinaryFulltext, getCacheSize, read, readCollectionRowArray, readSelectionRows, readSimpleRow, receiveInvalidations, remove, rollback, sendInvalidations, writerollbackpublic static Map<String,Serializable> testProps
protected static Map<String,JDBCMapper.CursorResult> cursorResults
public static final String TEST_UPGRADE
public static final String TEST_UPGRADE_VERSIONS
public static final String TEST_UPGRADE_LAST_CONTRIBUTOR
public static final String TEST_UPGRADE_LOCKS
protected TableUpgrader tableUpgrader
protected boolean clusteringEnabled
protected static final String NOSCROLL_ID
public JDBCMapper(Model model, Session.PathResolver pathResolver, SQLInfo sqlInfo, ClusterInvalidator clusterInvalidator, boolean noSharing, RepositoryImpl repository)
model - the modelpathResolver - the path resolver (used for startswith queries)sqlInfo - the sql infoclusterInvalidator - the cluster invalidatornoSharing - whether to use no-sharing mode for the connectionrepository - public int getTableSize(String tableName)
getTableSize in interface Mapperpublic void createDatabase(String ddlMode)
MappercreateDatabase in interface MapperddlMode - the DDL execution modeprotected String getTableName(String origName)
protected void createTables(String ddlMode) throws SQLException
SQLExceptionprotected void upgradeTable(String tableKey, List<Column> addedColumns, String ddlMode, SQLStatement.ListCollector ddlCollector) throws SQLException
SQLExceptionprotected static Set<String> findTableNames(DatabaseMetaData metadata, String schemaName) throws SQLException
SQLExceptionpublic int getClusterNodeIdType()
getClusterNodeIdType in interface Mapperpublic void createClusterNode(Serializable nodeId)
MappercreateClusterNode in interface Mapperpublic void removeClusterNode(Serializable nodeId)
MapperremoveClusterNode in interface Mapperprotected void deleteClusterInvals(Serializable nodeId) throws SQLException
SQLExceptionpublic void insertClusterInvalidations(Serializable nodeId, Invalidations invalidations)
MapperinsertClusterInvalidations in interface Mapperprotected static final String join(Collection<String> strings, char sep)
public Invalidations getClusterInvalidations(Serializable nodeId)
MappergetClusterInvalidations in interface Mapperpublic Serializable getRootId(String repositoryId)
Mapperpublic void setRootId(Serializable repositoryId, Serializable id)
Mapperprotected QueryMaker findQueryMaker(String queryType)
protected void prepareUserReadAcls(QueryFilter queryFilter)
public PartialList<Serializable> query(String query, String queryType, QueryFilter queryFilter, boolean countTotal)
Mapperpublic PartialList<Serializable> query(String query, String queryType, QueryFilter queryFilter, long countUpTo)
Mapperquery in interface Mapperquery - the queryqueryFilter - the query filtercountUpTo - if -1, count the total size without offset/limit.0, don't count the total size.n, count the total number if there are less than n documents otherwise set the size to
-1.public int setToPreparedStatement(PreparedStatement ps, int i, Serializable object) throws SQLException
SQLExceptionpublic IterableQueryResult queryAndFetch(String query, String queryType, QueryFilter queryFilter, boolean distinctDocuments, Object... params)
MapperqueryAndFetch in interface Mapperquery - the queryqueryType - the query typequeryFilter - the query filterdistinctDocuments - if true then a maximum of one row per document will be returnedparams - optional query-type-dependent parameterspublic ScrollResult scroll(String query, int batchSize, int keepAliveSeconds)
MapperkeepAliveSeconds delay.protected void checkForTimedoutScroll()
protected ScrollResult scrollSearch(String query, int batchSize, int keepAliveSeconds)
protected void registerCursor(String scrollId, PreparedStatement ps, ResultSet rs, int batchSize, int keepAliveSeconds)
protected boolean unregisterCursor(String scrollId)
protected ScrollResult defaultScroll(String query)
public ScrollResult scroll(String scrollId)
MapperscrollId is part of the previous ScrollResult response.public Set<Serializable> getAncestorsIds(Collection<Serializable> ids)
MappergetAncestorsIds in interface Mapperids - the idsprotected Set<Serializable> getAncestorsIdsIterative(Collection<Serializable> ids)
public void updateReadAcls()
updateReadAcls in interface Mapperpublic void rebuildReadAcls()
rebuildReadAcls in interface Mapperprotected Connection connection(boolean autocommit)
protected Lock callInTransaction(JDBCMapper.LockCallable callable, boolean tx)
Called under #serializationLock.
public Lock getLock(Serializable id)
Mapper
If the document does not exist, null is returned.
public Lock setLock(Serializable id, Lock lock)
Mapper
If the document is already locked, returns its existing lock status (there is no re-locking, Mapper.removeLock(java.io.Serializable, java.lang.String, boolean)
must be called first).
public Lock removeLock(Serializable id, String owner, boolean force)
MapperThe previous lock is returned.
If owner is null then the lock is unconditionally removed.
If owner is not null, it must match the existing lock owner for the lock to be removed. If it
doesn't match, the returned lock will return true for Lock.getFailed().
removeLock in interface Mapperid - the document idforce - true to just do the remove and not return the previous lockpublic void markReferencedBinaries()
MappermarkReferencedBinaries in interface Mapperprotected static String systemToString(Object o)
public void start(Xid xid, int flags) throws XAException
start in interface XAResourceXAExceptionpublic void end(Xid xid, int flags) throws XAException
end in interface XAResourceXAExceptionpublic int prepare(Xid xid) throws XAException
prepare in interface XAResourceXAExceptionpublic void commit(Xid xid, boolean onePhase) throws XAException
commit in interface XAResourceXAExceptionpublic void forget(Xid xid) throws XAException
forget in interface XAResourceXAExceptionpublic Xid[] recover(int flag) throws XAException
recover in interface XAResourceXAExceptionpublic boolean setTransactionTimeout(int seconds) throws XAException
setTransactionTimeout in interface XAResourceXAExceptionpublic int getTransactionTimeout() throws XAException
getTransactionTimeout in interface XAResourceXAExceptionpublic boolean isSameRM(XAResource xares) throws XAException
isSameRM in interface XAResourceXAExceptionpublic boolean isConnected()
isConnected in interface Mapperpublic void disconnect()
disconnect in interface MapperCopyright © 2016 Nuxeo SA. All rights reserved.