public class JDBCRowMapper extends JDBCConnection implements RowMapper
JDBCRowMapper
maps Row
s to and from a JDBC database.RowMapper.CopyResult, RowMapper.IdWithTypes, RowMapper.NodeInfo, RowMapper.RowBatch, RowMapper.RowUpdate
Modifier and Type | Field and Description |
---|---|
static int |
DEBUG_MAX_TREE |
static int |
UPDATE_BATCH_SIZE |
connection, countExecutes, executeCount, logger, MAX_CONNECTION_TRIES
Constructor and Description |
---|
JDBCRowMapper(Model model,
SQLInfo sqlInfo,
XADataSource xadatasource,
ClusterNodeHandler clusterNodeHandler,
JDBCConnectionPropagator connectionPropagator,
boolean noSharing) |
Modifier and Type | Method and Description |
---|---|
int |
cleanupDeletedRows(int max,
Calendar beforeTime)
Clean up soft-deleted rows.
|
void |
clearCache()
Clears the mapper's cache (if any)
|
void |
close() |
RowMapper.CopyResult |
copy(RowMapper.IdWithTypes source,
Serializable destParentId,
String destName,
Row overwriteRow)
Copies the hierarchy starting from a given row to a new parent with a new
name.
|
Serializable |
generateNewId()
Computes a new unique id.
|
long |
getCacheSize()
Evaluate the cached elements size
|
List<? extends RowId> |
read(Collection<RowId> rowIds,
boolean cacheOnly)
Reads a set of rows for the given
RowId s. |
Serializable[] |
readCollectionRowArray(RowId rowId)
Gets an array for a
CollectionFragment from the database, given
its table name and id. |
List<Row> |
readSelectionRows(SelectionType selType,
Serializable selId,
Serializable filter,
Serializable criterion,
boolean limitToOne)
Reads the rows corresponding to a selection.
|
Row |
readSimpleRow(RowId rowId)
Gets a row for a
SimpleFragment from the database, given its
table name and id. |
Invalidations.InvalidationsPair |
receiveInvalidations()
Processes and returns the invalidations queued for processing by the
cache (if any).
|
List<RowMapper.NodeInfo> |
remove(RowMapper.NodeInfo rootInfo)
Deletes a hierarchy and returns information to generate invalidations.
|
void |
rollback(Xid xid)
Rollback the XA Resource.
|
void |
sendInvalidations(Invalidations invalidations)
Post-transaction invalidations notification.
|
void |
write(RowMapper.RowBatch batch)
Writes a set of rows.
|
getIdentification
public static final int UPDATE_BATCH_SIZE
public static final int DEBUG_MAX_TREE
public JDBCRowMapper(Model model, SQLInfo sqlInfo, XADataSource xadatasource, ClusterNodeHandler clusterNodeHandler, JDBCConnectionPropagator connectionPropagator, boolean noSharing) throws StorageException
StorageException
public void close()
close
in class JDBCConnection
public Invalidations.InvalidationsPair receiveInvalidations() throws StorageException
RowMapper
Called pre-transaction by session start or transactionless save;
receiveInvalidations
in interface RowMapper
null
StorageException
public void sendInvalidations(Invalidations invalidations) throws StorageException
RowMapper
Called post-transaction by session commit/rollback or transactionless save.
sendInvalidations
in interface RowMapper
invalidations
- the known invalidations to send to others, or
null
StorageException
public void clearCache()
RowMapper
Called after a rollback, or a manual clear through RepositoryStatus MBean.
clearCache
in interface RowMapper
public long getCacheSize()
RowMapper
getCacheSize
in interface RowMapper
public void rollback(Xid xid) throws XAException
RowMapper
This is in the RowMapper
interface because on rollback the cache
must be invalidated.
rollback
in interface RowMapper
XAException
public Serializable generateNewId() throws StorageException
RowMapper
generateNewId
in interface RowMapper
StorageException
public List<? extends RowId> read(Collection<RowId> rowIds, boolean cacheOnly) throws StorageException
RowMapper
RowId
s.
For each requested row, either a Row
is found and returned, or a
RowId
(not implementing Row
) is returned to signify an
absent row.
read
in interface RowMapper
rowIds
- the row ids (including their table name)cacheOnly
- if true
, only hit memoryRow
s (or RowId
s if the row was
absent from the database). Order is not the same as the input
rowIds
StorageException
public void write(RowMapper.RowBatch batch) throws StorageException
RowMapper
write
in interface RowMapper
batch
- the set of rows and the operations to do on themStorageException
public int cleanupDeletedRows(int max, Calendar beforeTime) throws StorageException
Rows deleted more recently than the beforeTime are left alone. Only a limited number of rows may be deleted, to prevent transaction during too long.
max
- the maximum number of rows to delete at a timebeforeTime
- the maximum deletion time of the rows to deleteStorageException
public Row readSimpleRow(RowId rowId) throws StorageException
RowMapper
SimpleFragment
from the database, given its
table name and id. If the row doesn't exist, null
is returned.readSimpleRow
in interface RowMapper
rowId
- the row idnull
StorageException
public Serializable[] readCollectionRowArray(RowId rowId) throws StorageException
RowMapper
CollectionFragment
from the database, given
its table name and id. If no rows are found, an empty array is returned.readCollectionRowArray
in interface RowMapper
rowId
- the row idStorageException
public List<Row> readSelectionRows(SelectionType selType, Serializable selId, Serializable filter, Serializable criterion, boolean limitToOne) throws StorageException
RowMapper
readSelectionRows
in interface RowMapper
selType
- the selection typeselId
- the selection id (parent id for a hierarchy selection)filter
- the filter value (name for a hierarchy selection)criterion
- an optional additional criterion depending on the
selection type (complex prop flag for a hierarchy selection)limitToOne
- whether to stop after one row retrievedStorageException
public RowMapper.CopyResult copy(RowMapper.IdWithTypes source, Serializable destParentId, String destName, Row overwriteRow) throws StorageException
RowMapper
If the new parent is null
, then this is a version creation, which
doesn't recurse in regular children.
If overwriteRow
is passed, the copy is done onto this existing
node as its root (version restore) instead of creating a new node in the
parent.
copy
in interface RowMapper
source
- the id, primary type and mixin types of the row to copydestParentId
- the new parent id, or null
destName
- the new nameoverwriteRow
- when not null
, the copy is done onto this
existing row, and the values are set in hierarchyStorageException
public List<RowMapper.NodeInfo> remove(RowMapper.NodeInfo rootInfo) throws StorageException
RowMapper
remove
in interface RowMapper
rootInfo
- info about the root to be deleted with its children (root
id, and the rest is for invalidations)StorageException
Copyright © 2013 Nuxeo SA. All Rights Reserved.