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
.
Mapper.Identification
RowMapper.CopyResult, RowMapper.IdWithTypes, RowMapper.NodeInfo, RowMapper.RowBatch, RowMapper.RowUpdate
Modifier and Type | Field and Description |
---|---|
static String |
TEST_UPGRADE |
static String |
TEST_UPGRADE_FULLTEXT |
static String |
TEST_UPGRADE_LAST_CONTRIBUTOR |
static String |
TEST_UPGRADE_LOCKS |
static String |
TEST_UPGRADE_VERSIONS |
static Map<String,Serializable> |
testProps |
DEBUG_MAX_TREE, UPDATE_BATCH_SIZE
connection, countExecutes, executeCount, logger
CLOSE, GET_IDENTIFICATION
TMENDRSCAN, TMFAIL, TMJOIN, TMNOFLAGS, TMONEPHASE, TMRESUME, TMSTARTRSCAN, TMSUCCESS, TMSUSPEND, XA_OK, XA_RDONLY
Constructor and Description |
---|
JDBCMapper(Model model,
Session.PathResolver pathResolver,
SQLInfo sqlInfo,
XADataSource xadatasource,
ClusterNodeHandler clusterNodeHandler,
JDBCConnectionPropagator connectionPropagator)
Creates a new Mapper.
|
Modifier and Type | Method and Description |
---|---|
void |
commit(Xid xid,
boolean onePhase) |
void |
createClusterNode()
Informs the cluster that this node exists.
|
void |
createDatabase()
Creates the necessary structures in the database.
|
void |
end(Xid xid,
int flags) |
void |
forget(Xid xid) |
Set<Serializable> |
getAncestorsIds(Collection<Serializable> ids)
Gets the ids for all the ancestors of the given row ids.
|
Invalidations |
getClusterInvalidations()
Gets the invalidations from other cluster nodes.
|
Lock |
getLock(Serializable id)
Gets the lock state of a document.
|
Serializable |
getRootId(Serializable repositoryId)
Gets the root id for a given repository, if registered.
|
int |
getTableSize(String tableName) |
int |
getTransactionTimeout() |
void |
insertClusterInvalidations(Invalidations invalidations)
Inserts the invalidation rows for the other cluster nodes.
|
boolean |
isSameRM(XAResource xares) |
void |
markReferencedBinaries(BinaryGarbageCollector gc)
Marks the binaries referenced by this mapper with the referenced binary
garbage collector.
|
int |
prepare(Xid xid) |
PartialList<Serializable> |
query(String query,
String queryType,
QueryFilter queryFilter,
boolean countTotal)
Makes a NXQL query to the database.
|
IterableQueryResult |
queryAndFetch(String query,
String queryType,
QueryFilter queryFilter,
Object... params)
Makes a query to the database and returns an iterable (which must be
closed when done).
|
void |
rebuildReadAcls() |
Xid[] |
recover(int flag) |
void |
removeClusterNode()
Removes this node from the cluster.
|
Lock |
removeLock(Serializable id,
String owner,
boolean force)
Removes a lock from a document.
|
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.
|
boolean |
setTransactionTimeout(int seconds) |
void |
start(Xid xid,
int flags) |
void |
updateReadAcls() |
clearCache, close, copy, isClusterReconnecting, read, readCollectionRowArray, readSelectionRows, readSimpleRow, receiveInvalidations, remove, rollback, sendInvalidations, write
getIdentification
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, getIdentification
clearCache, copy, isClusterReconnecting, read, readCollectionRowArray, readSelectionRows, readSimpleRow, receiveInvalidations, remove, rollback, sendInvalidations, write
rollback
public static Map<String,Serializable> testProps
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
public static final String TEST_UPGRADE_FULLTEXT
public JDBCMapper(Model model, Session.PathResolver pathResolver, SQLInfo sqlInfo, XADataSource xadatasource, ClusterNodeHandler clusterNodeHandler, JDBCConnectionPropagator connectionPropagator) throws StorageException
model
- the modelpathResolver
- the path resolver (used for startswith queries)sqlInfo
- the sql infoxadatasource
- the XA datasource to use to get connectionsclusterNodeHandler
- the cluster node handlerconnectionPropagator
- the connection propagatorStorageException
public int getTableSize(String tableName)
getTableSize
in interface Mapper
public void createDatabase() throws StorageException
Mapper
createDatabase
in interface Mapper
StorageException
public void createClusterNode() throws StorageException
Mapper
createClusterNode
in interface Mapper
StorageException
public void removeClusterNode() throws StorageException
Mapper
removeClusterNode
in interface Mapper
StorageException
public void insertClusterInvalidations(Invalidations invalidations) throws StorageException
Mapper
insertClusterInvalidations
in interface Mapper
StorageException
public Invalidations getClusterInvalidations() throws StorageException
Mapper
getClusterInvalidations
in interface Mapper
StorageException
public Serializable getRootId(Serializable repositoryId) throws StorageException
Mapper
getRootId
in interface Mapper
repositoryId
- the repository id, usually 0StorageException
public void setRootId(Serializable repositoryId, Serializable id) throws StorageException
Mapper
setRootId
in interface Mapper
repositoryId
- the repository id, usually 0id
- the root idStorageException
public PartialList<Serializable> query(String query, String queryType, QueryFilter queryFilter, boolean countTotal) throws StorageException
Mapper
query
in interface Mapper
query
- the queryqueryFilter
- the query filtercountTotal
- if true
, count the total size without
limit/offsetStorageException
public IterableQueryResult queryAndFetch(String query, String queryType, QueryFilter queryFilter, Object... params) throws StorageException
Mapper
queryAndFetch
in interface Mapper
query
- the queryqueryType
- the query typequeryFilter
- the query filterparams
- optional query-type-dependent parametersStorageException
public Set<Serializable> getAncestorsIds(Collection<Serializable> ids) throws StorageException
Mapper
getAncestorsIds
in interface Mapper
ids
- the idsStorageException
public void updateReadAcls() throws StorageException
updateReadAcls
in interface Mapper
StorageException
public void rebuildReadAcls() throws StorageException
rebuildReadAcls
in interface Mapper
StorageException
public Lock getLock(Serializable id) throws StorageException
Mapper
If the document does not exist, null
is returned.
getLock
in interface Mapper
id
- the document idnull
when there is no lockStorageException
public Lock setLock(Serializable id, Lock lock) throws StorageException
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).
setLock
in interface Mapper
id
- the document idlock
- the lock object to setnull
if locking succeeded, or the existing lock if
locking failed, or aStorageException
public Lock removeLock(Serializable id, String owner, boolean force) throws StorageException
Mapper
The 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 Mapper
id
- the document idforce
- true
to just do the remove and not return the
previous lockStorageException
public void markReferencedBinaries(BinaryGarbageCollector gc) throws StorageException
Mapper
markReferencedBinaries
in interface Mapper
gc
- the binary garbage collectorStorageException
public void start(Xid xid, int flags) throws XAException
start
in interface XAResource
XAException
public void end(Xid xid, int flags) throws XAException
end
in interface XAResource
XAException
public int prepare(Xid xid) throws XAException
prepare
in interface XAResource
XAException
public void commit(Xid xid, boolean onePhase) throws XAException
commit
in interface XAResource
XAException
public void forget(Xid xid) throws XAException
forget
in interface XAResource
XAException
public Xid[] recover(int flag) throws XAException
recover
in interface XAResource
XAException
public boolean setTransactionTimeout(int seconds) throws XAException
setTransactionTimeout
in interface XAResource
XAException
public int getTransactionTimeout() throws XAException
getTransactionTimeout
in interface XAResource
XAException
public boolean isSameRM(XAResource xares) throws XAException
isSameRM
in interface XAResource
XAException
Copyright © 2011 Nuxeo SA. All Rights Reserved.