public class Db extends Object implements Session, Cloneable
ConnectionManager
which is responsible for the physical JDBC-connection. However, there
is no 1:1 relationship between a Db and a physical connection. This is up
to the connection manager.
Local Db connections are used in client applications running in 2-tier mode
or in application servers.
The configuration is achieved by a property file, which is located
by the SessionInfo passed to the Db.
Local connections can be either a DataSource bound via JNDI or a direct
JDBC connection. JNDI is used in application servers, for example running
a JRuby on Rails application from within Glassfish (see tentackle-web).
JDBC connections are for standalone 2-tier applications or Tentackle application servers.
For local connections via JDBC the file contains at least the following properties:
driver=jdbc-driver url=jdbc-url Example: driver=org.postgresql.Driver url=jdbc:postgresql://gonzo.krake.local/erpLocal connections via JNDI need only the url. The url starts with "jndi:" and is followed by the JNDI-name. The optional database backend type is only necessary if it cannot be determined from the connection's metadata.
url=jndi:name[:database-type] Example: url=jndi:jdbc/erpPoolFor remote connections only one line is required at minimum:
url=rmi://hostname[:port]/service Example: url=rmi://gonzo.krake.local:28004/ErpServerThe port is optional and defaults to 1099 (the default RMI registry).
Optionally, the following properties can be defined:
For local connections via JDBC:
user=fixed-user password=fixed-password
backendinfo=property-file
For local connections via JDBC or JNDI:
IdSource. The default source is ObjectId.
idsource=id-source-descriptorSee
IdSourceConfigurator for details.
For remote connections, the properties (session info) will be sent to the server. This can be used to set some application specific options or to tune the connection.
| Modifier and Type | Field and Description |
|---|---|
static String |
CIPHER_SUITES
The property key for the SSL cipher suites.
|
static String |
PROPERTY_IDSOURCE
property key for IdSource.
|
static String |
PROTOCOLS
The property key for the SSL protocols.
|
static String |
SOCKET_FACTORY
The property key for the socket factory.
|
| Constructor and Description |
|---|
Db(ConnectionManager conMgr,
SessionInfo sessionInfo)
Creates an instance of a logical db connection.
|
| Modifier and Type | Method and Description |
|---|---|
void |
assertNotRemote()
asserts that this is not a remote connection
|
void |
assertNoTxRunning()
Asserts that no transaction is running.
|
void |
assertOpen()
Asserts that the database is open.
|
void |
assertOwnerThread()
Asserts db is not used by another thread than the ownerthread.
|
void |
assertRemote()
asserts that this is a remote connection
|
void |
assertTxRunning()
Asserts that a transaction with the given voucher is running.
|
long |
begin() |
long |
begin(String txName)
Starts a transaction.
Does nothing if a transaction is already running! |
boolean |
checkForDeadLink(SQLException ex)
Checks for a dead communications link.
If the link is down, for example the database server closed it, the connection is marked dead. |
void |
clearCloned()
Clears the cloned state.
|
void |
clearPassword()
Clears all passwords (stored in char[]-arrays) so
that they are no more visible in memory.
|
Db |
clone()
Clones a logical connection.
|
void |
close() |
boolean |
commit(long txVoucher)
Commits a transaction if the corresponding begin() has started it.
|
boolean |
commitImmediately()
Commits the current transaction, if pending.
|
int |
compareTo(Session session)
Compares two db instances.
|
Connection |
connect()
Creates a physical low level connection to the local db server via JDBC
using this Db (authentication by userinfo or fixed user/password).
|
PreparedStatementWrapper |
createPreparedStatement(String sql)
Creates a one-shot prepared statement.
Uses ResultSet.TYPE_FORWARD_ONLY and ResultSet.CONCUR_READ_ONLY. |
PreparedStatementWrapper |
createPreparedStatement(String sql,
int resultSetType,
int resultSetConcurrency)
Creates a one-shot prepared statement.
|
org.tentackle.persist.rmi.RemoteDelegate |
createRemoteDelegate(String className)
Creates the remote delegate.
|
StatementWrapper |
createStatement()
Creates a non-prepared statement.
|
StatementWrapper |
createStatement(int resultSetType)
Creates a non-prepared statement.
|
StatementWrapper |
createStatement(int resultSetType,
int resultSetConcurrency)
Creates a non-prepared statement.
|
boolean |
equals(Object obj) |
protected void |
finalize()
finalizer if connection is broken
|
void |
forceDetached()
Detach the db.
Used in execption handling to cleanup all pending statements and result sets. |
static Collection<Db> |
getAllOpenDb()
Gets a list of all currently open Db sessions.
|
Backend |
getBackend()
Gets the database backend.
|
BackendInfo |
getBackendInfo()
Gets the backend info.
|
Db |
getClonedFromDb()
Gets the original db if this db is cloned.
|
Collection<CommitTxRunnable> |
getCommitTxRunnables()
Gets the currently registered commit runnables.
|
IdSource |
getDefaultIdSource()
Gets the default
IdSource. |
SessionTaskDispatcher |
getDispatcher()
Gets the dispatcher for this session.
The dispatcher can be used to submit asynchroneous tasks in a serial manner. |
int |
getFetchSize()
Gets the default fetchsize
|
String |
getIdSourceConfiguration()
Gets the ID-Source configuration.
|
int |
getImmediateCommitTxLevel()
Gets the pending txLevel after an immediate commit.
|
int |
getImmediateRollbackTxLevel()
Gets the pending txLevel after an immediate rollback.
|
int |
getInstanceNumber()
Gets the unique instance number of this Db.
|
long |
getKeepAliveInterval() |
long |
getLogModificationTxId()
Returns the current transaction id from the last BEGIN modification log.
|
int |
getMaxRows()
gets the maximum number of rows in resultsets.
|
String |
getName()
Gets the db name.
Consists of the instance number, the connection id and the connection group id. |
Thread |
getOwnerThread()
Gets the owner thread.
|
Collection<PersistenceVisitor> |
getPersistenceVisitors()
Gets the currently registered persistence visitors.
|
SessionPool |
getPool()
Gets the pool manager.
|
int |
getPoolId()
Gets the poolid.
|
PreparedStatementWrapper |
getPreparedStatement(StatementKey stmtKey,
boolean alwaysPrepare,
int resultSetType,
int resultSetConcurrency,
Supplier<String> sqlSupplier)
Gets the prepared statement.
|
PreparedStatementWrapper |
getPreparedStatement(StatementKey stmtKey,
boolean alwaysPrepare,
Supplier<String> sqlSupplier)
|
RemoteDbConnection |
getRemoteConnection()
Gets the remote connection object.
|
RemoteDbSession |
getRemoteDbSession()
Gets the remote session object.
|
org.tentackle.persist.rmi.RemoteDelegate |
getRemoteDelegate(int delegateId)
Gets the remote delegate by its id.
|
String |
getRemoteName()
Gets the name of the remote server application.
|
RemoteSession |
getRemoteSession() |
Collection<RollbackTxRunnable> |
getRollbackTxRunnables()
Gets the currently registered rollback runnables.
|
int |
getSessionGroupId() |
int |
getSessionId()
Gets the connection id.
|
SessionInfo |
getSessionInfo()
Gets the current user info.
|
ConnectionManager |
getSessionManager()
Gets the connection manager for this Db.
|
int |
getTxLevel()
Gets the transaction nesting level.
|
String |
getTxName()
Gets the optional transaction name.
|
long |
getTxNumber()
Transactions get a unique transaction number by
counting the transactions per Db instance.
|
AbstractDbObject<?> |
getTxObject()
Gets the optional transaction object.
|
int |
getUpdateCount()
Gets the number of objects modified since the last begin().
|
String |
getUrl() |
int |
groupWith(int sessionId) |
int |
hashCode() |
void |
invalidateTxLevel()
Marks the txLevel invalid.
|
boolean |
isAlive()
Checks whether the db connection is still in use.
|
boolean |
isClientTx()
Checks whether current transaction was initiated by a remote client.
|
boolean |
isCloned()
Gets the cloned state.
|
boolean |
isCountModificationAllowed()
Checks whether objects are allowed to count modifications.
|
boolean |
isCrashed()
Gets the crash flag.
May be invoked from any thread. |
boolean |
isLogModificationAllowed()
Gets the state of logModificationAllowed.
|
boolean |
isLogModificationDeferred()
Gets the state for logModificationDeferred.
|
boolean |
isLogModificationTxEnabled()
Gets the value of logModificationTx.
|
boolean |
isOpen()
Gets the connection state.
|
boolean |
isPersistenceOperationAllowed(AbstractDbObject<?> object,
char modType)
Checks whether a persistence operation is allowed.
This is determined by consulting the PersistenceVisitors. |
boolean |
isPooled()
Checks whether this Db is pooled.
|
boolean |
isReadOnly()
Returns whether Db is readonly.
|
boolean |
isRemote()
Gets the type of the logical connection.
|
boolean |
isTxLevelValid()
Returns whether the txLevel is valid.
|
boolean |
isTxRunning()
Gets the current transaction state.
Technically, a transaction is running if the autocommit is turned off. |
void |
logBeginTx()
Creates a begin modification log if necessary.
|
void |
logCommitTx()
Creates a commit modification log if necessary.
|
void |
logException(Logger logger,
Logger.Level level,
String msg,
Throwable e)
Logs an exception.
|
void |
open()
Open a database connection.
If the login failes due to wrong passwords or denied access by the application server, the method handleConnectException(java.lang.Exception) is invoked. |
List<ModificationLog> |
popModificationLogsOfTransaction()
Returns the
ModificationLogs of the current transaction. |
static int |
prepareRemoteDelegate(Class<?> clazz)
Prepares a
RemoteDelegate. |
void |
pushModificationLogOfTransaction(ModificationLog log)
Pushes a
ModificationLog to the list of modlogs of the current transaction. |
boolean |
registerCloseHandler(SessionCloseHandler closeHandler)
Registers a close handler.
|
DbTransactionHandle |
registerCommitTxRunnable(CommitTxRunnable commitRunnable)
Registers a
CommitTxRunnable to be invoked just before
committing a transaction. |
static boolean |
registerGlobalCloseHandler(SessionCloseHandler closeHandler)
Registers a global close handler.
|
DbTransactionHandle |
registerPersistenceVisitor(PersistenceVisitor visitor)
Registers a
PersistenceVisitor to be invoked just before
performing a persistence operation.Notice that the visitor must be registered within the transaction, i.e. |
DbTransactionHandle |
registerRollbackTxRunnable(RollbackTxRunnable rollbackRunnable)
Registers a
RollbackTxRunnable to be invoked just before
rolling back a transaction. |
boolean |
rollback(long txVoucher) |
boolean |
rollback(long txVoucher,
boolean withLog)
Rolls back a transaction if the corresponding begin() has started it.
|
boolean |
rollbackImmediately()
Rolls back the current transaction, if pending.
|
boolean |
rollbackSilently(long txVoucher) |
void |
setAlive(boolean alive)
Sets the db connection's alive state.
|
void |
setCountModificationAllowed(boolean countModificationAllowed)
Defines whether objects are allowed to count modifications.
|
void |
setCrashed(boolean crashed)
Sets the crash flag.
The db may be marked as crashed to reduce logging of succeeding errors. |
void |
setDefaultIdSource(IdSource idSource)
Set the default
IdSource.This is the source that is used to generate unique object IDs if classes did not configure their own source. |
void |
setFetchSize(int fetchSize)
Sets the default fetchsize for all "wrapped" statements
(PreparedStatementWrapper and StatementWrapper)
|
void |
setIdConfiguration(String idConfig)
Sets the ID-Source configuration.
|
void |
setKeepAliveInterval(long keepAliveInterval) |
void |
setLogModificationAllowed(boolean logModificationAllowed)
Sets the modification allowed state.
|
void |
setLogModificationDeferred(boolean logModificationDeferred)
Sets the modification logging deferred state for the current transaction.
In deferred mode the ModificationLogs are not written to the database. |
void |
setLogModificationTxEnabled(boolean logModificationTxEnabled)
Turn transaction-logging on or off.
|
void |
setLogModificationTxId(long logModificationTxId)
Sets the transaction id.
|
void |
setMaxRows(int maxRows)
sets the maximum number of rows in resultsets.
|
void |
setOwnerThread(Thread ownerThread)
Sets the exclusive owner thread.
|
void |
setPool(SessionPool sessionPool)
Sets the pool manager.
|
void |
setPoolId(int poolId)
Sets the pool id.
|
void |
setReadOnly(boolean readOnly)
Sets the db to readonly.
|
void |
setSessionGroupId(int number)
Sets the group number for this db.
This is an optional number describing groups of db-connections, which is particulary useful in rmi-servers: if one connection fails, all others should be closed as well. |
void |
setSessionInfo(SessionInfo sessionInfo)
Sets the userInfo.
|
void |
setTxObject(AbstractDbObject<?> txObject)
Sets the optional transaction object.
By default, whenever a transaction is initiated by a persistence operation of a AbstractDbObject, that object becomes the "parent" of the
transaction.The txObject is mainly used for logging and enhanced auditing (partial history) during transactions.The txObject is cleared at the end of the transaction. |
String |
toString() |
<T> T |
transaction(TransactionEnvelope<T> txe) |
<T> T |
transaction(TransactionEnvelope<T> txe,
String txName) |
boolean |
unregisterCloseHandler(SessionCloseHandler closeHandler)
Unregisters a close handler.
|
CommitTxRunnable |
unregisterCommitTxRunnable(DbTransactionHandle handle)
Unregisters a
CommitTxRunnable. |
static boolean |
unregisterGlobalCloseHandler(SessionCloseHandler closeHandler)
Unregisters a global close handler.
|
PersistenceVisitor |
unregisterPersistenceVisitor(DbTransactionHandle handle)
Unegisters a
PersistenceVisitor. |
RollbackTxRunnable |
unregisterRollbackTxRunnable(DbTransactionHandle handle)
Unregisters a
RollbackTxRunnable. |
applyTo, applyTo, assertCurrentSessionValid, clearCurrent, getCurrentSession, getSession, isCurrent, makeCurrent, setCurrentSessionpublic static final String PROPERTY_IDSOURCE
public static final String SOCKET_FACTORY
public static final String CIPHER_SUITES
public static final String PROTOCOLS
public Db(ConnectionManager conMgr, SessionInfo sessionInfo)
conMgr - the connection manager to use for this db, unused for local connectionssessionInfo - user informationpublic static boolean registerGlobalCloseHandler(SessionCloseHandler closeHandler)
closeHandler - the handlerpublic static boolean unregisterGlobalCloseHandler(SessionCloseHandler closeHandler)
closeHandler - the handlerpublic static Collection<Db> getAllOpenDb()
public final int getInstanceNumber()
getInstanceNumber in interface Sessionpublic String getName()
public int compareTo(Session session)
compareTo in interface Comparable<Session>session - the session to compare this db withpublic ConnectionManager getSessionManager()
getSessionManager in interface Sessionpublic void setPool(SessionPool sessionPool)
sessionPool - the db pool, null = not pooledpublic SessionPool getPool()
public boolean isPooled()
public void setPoolId(int poolId)
poolId - the ID given by the pool (> 0), 0 = not used (free Db), -1 if removed from poolpublic int getPoolId()
public boolean isReadOnly()
public void setReadOnly(boolean readOnly)
If a database is readonly, no updates, deletes or inserts are possible. Any attempt to do so results in a persistence exception.
readOnly - true if readonlypublic RemoteDbConnection getRemoteConnection()
public RemoteDbSession getRemoteDbSession()
public Connection connect() throws SQLException
SQLException - if connection failedpublic void assertOwnerThread()
public void assertOpen()
public void assertTxRunning()
public void assertNoTxRunning()
public void assertNotRemote()
public void assertRemote()
public boolean isAlive()
StatementWrapper or PreparedStatementWrapper is used
(i.e executeQuery or executeUpdate), the db connection is set to be alive.
Some other thread may clear this flag regulary and check whether it has
been set in the meantime.public void setAlive(boolean alive)
public long getKeepAliveInterval()
getKeepAliveInterval in interface Sessionpublic void setKeepAliveInterval(long keepAliveInterval)
setKeepAliveInterval in interface Sessionpublic void setIdConfiguration(String idConfig)
idConfig - the configurationpublic String getIdSourceConfiguration()
public SessionTaskDispatcher getDispatcher()
getDispatcher in interface Sessionpublic void logException(Logger logger, Logger.Level level, String msg, Throwable e)
e - the exception head, null if nonemsg - the optional message, null if nonelogger - the loggerlevel - the logging levelpublic boolean checkForDeadLink(SQLException ex)
ex - the sql exceptionManagedConnection.setDead(boolean)public void open()
handleConnectException(java.lang.Exception) is invoked.public void clearPassword()
public boolean registerCloseHandler(SessionCloseHandler closeHandler)
closeHandler - the handlerpublic boolean unregisterCloseHandler(SessionCloseHandler closeHandler)
closeHandler - the handlerprotected void finalize()
throws Throwable
public void setCrashed(boolean crashed)
crashed - the crash flagpublic boolean isCrashed()
public boolean isOpen()
public long getTxNumber()
public String getTxName()
public int getTxLevel()
public void invalidateTxLevel()
Will suppress any checks and warnings.
public boolean isTxLevelValid()
public int getImmediateRollbackTxLevel()
public int getImmediateCommitTxLevel()
public void setTxObject(AbstractDbObject<?> txObject)
AbstractDbObject, that object becomes the "parent" of the
transaction.txObject is mainly used for logging and enhanced auditing (partial history) during transactions.txObject is cleared at the end of the transaction.txObject - the transaction object, null to clearpublic AbstractDbObject<?> getTxObject()
public <T> T transaction(TransactionEnvelope<T> txe, String txName)
transaction in interface Sessionpublic <T> T transaction(TransactionEnvelope<T> txe)
transaction in interface Sessionpublic long begin(String txName)
public boolean isClientTx()
public void logBeginTx()
public void logCommitTx()
public int getUpdateCount()
public DbTransactionHandle registerPersistenceVisitor(PersistenceVisitor visitor)
PersistenceVisitor to be invoked just before
performing a persistence operation.begin().
The visitors are automatically unregistered at the end of a transaction
(commit or rollback).visitor - the visitor to registerisPersistenceOperationAllowed(org.tentackle.persist.AbstractDbObject, char)public PersistenceVisitor unregisterPersistenceVisitor(DbTransactionHandle handle)
PersistenceVisitor.handle - the visitor's handle to unregisterpublic Collection<PersistenceVisitor> getPersistenceVisitors()
public boolean isPersistenceOperationAllowed(AbstractDbObject<?> object, char modType)
PersistenceVisitors.object - the persistence objectmodType - the modification typeregisterPersistenceVisitor(org.tentackle.persist.PersistenceVisitor)public DbTransactionHandle registerCommitTxRunnable(CommitTxRunnable commitRunnable)
CommitTxRunnable to be invoked just before
committing a transaction.commitRunnable - the runnable to registerpublic CommitTxRunnable unregisterCommitTxRunnable(DbTransactionHandle handle)
CommitTxRunnable.handle - the runnable's handle to unregisterpublic Collection<CommitTxRunnable> getCommitTxRunnables()
public DbTransactionHandle registerRollbackTxRunnable(RollbackTxRunnable rollbackRunnable)
RollbackTxRunnable to be invoked just before
rolling back a transaction.rollbackRunnable - the runnable to registerpublic RollbackTxRunnable unregisterRollbackTxRunnable(DbTransactionHandle handle)
RollbackTxRunnable.handle - the runnable's handle to unregisterpublic Collection<RollbackTxRunnable> getRollbackTxRunnables()
public boolean commit(long txVoucher)
public boolean commitImmediately()
Applications should use commit(long).
Invocations of this method will be logged as a warning.
public boolean rollbackSilently(long txVoucher)
rollbackSilently in interface Sessionpublic boolean rollback(long txVoucher,
boolean withLog)
txVoucher - the transaction voucher, 0 if ignore (nested tx)withLog - true if log via INFOpublic boolean rollbackImmediately()
Applications should use rollback(long).
Invocations of this method will be logged as a warning.
rollbackImmediately in interface Sessionpublic void forceDetached()
public int getSessionId()
getSessionId in interface Sessionpublic void setSessionGroupId(int number)
number - is the group number, 0 = no grouppublic int getSessionGroupId()
getSessionGroupId in interface Sessionpublic void setOwnerThread(Thread ownerThread)
Allows to detect other threads accidently using this db.
Caution: don't forget to clear!
setOwnerThread in interface SessionownerThread - the owner thread, null to clearpublic Thread getOwnerThread()
getOwnerThread in interface Sessionpublic StatementWrapper createStatement(int resultSetType, int resultSetConcurrency)
Non-prepared statements attach the db as soon as they are instatiated! The db is detached after executeUpdate or after executeQuery when its result set is closed.
resultSetType - a result set type; one of
ResultSet.TYPE_FORWARD_ONLY,
ResultSet.TYPE_SCROLL_INSENSITIVE, or
ResultSet.TYPE_SCROLL_SENSITIVEresultSetConcurrency - a concurrency type; one of
ResultSet.CONCUR_READ_ONLY or
ResultSet.CONCUR_UPDATABLEpublic StatementWrapper createStatement(int resultSetType)
resultSetType - a result set type; one of
ResultSet.TYPE_FORWARD_ONLY,
ResultSet.TYPE_SCROLL_INSENSITIVE, or
ResultSet.TYPE_SCROLL_SENSITIVEStatement object that will generate
ResultSet objects with the given type and
concurrency CONCUR_READ_ONLYpublic StatementWrapper createStatement()
Statement object that will generate
ResultSet objects with type TYPE_FORWARD_ONLY and
concurrency CONCUR_READ_ONLYpublic PreparedStatementWrapper getPreparedStatement(StatementKey stmtKey, boolean alwaysPrepare, int resultSetType, int resultSetConcurrency, Supplier<String> sqlSupplier)
Getting the prepared statement will attach the db to a connection. The db will be detached after executeUpdate() or executeQuery when its result set is closed.
stmtKey - the statement keyalwaysPrepare - true if always do a physical prepareresultSetType - one of ResultSet.TYPE_...resultSetConcurrency - one of ResultSet.CONCUR_...sqlSupplier - the SQL supplierpublic PreparedStatementWrapper getPreparedStatement(StatementKey stmtKey, boolean alwaysPrepare, Supplier<String> sqlSupplier)
stmtKey - the statement keyalwaysPrepare - true if always do a physical preparesqlSupplier - the SQL supplierpublic PreparedStatementWrapper createPreparedStatement(String sql, int resultSetType, int resultSetConcurrency)
Getting the prepared statement will attach the db to a connection. The db will be detached after executeUpdate() or executeQuery() when its result set is closed.
sql - the SQL coderesultSetType - one of ResultSet.TYPE_...resultSetConcurrency - one of ResultSet.CONCUR_...public PreparedStatementWrapper createPreparedStatement(String sql)
ResultSet.TYPE_FORWARD_ONLY and ResultSet.CONCUR_READ_ONLY.sql - the SQL codepublic boolean isTxRunning()
isTxRunning in interface Sessionpublic SessionInfo getSessionInfo()
getSessionInfo in interface Sessionpublic void setSessionInfo(SessionInfo sessionInfo)
sessionInfo - the session infopublic BackendInfo getBackendInfo()
public Db clone()
Connections may be cloned, which results in a new connection using the cloned userinfo of the original connection. If the old db is already open, the new db will be opened as well. If the old db is closed, the cloned db will be closed.
public Db getClonedFromDb()
public void clearCloned()
public boolean isCloned()
public int getFetchSize()
public void setFetchSize(int fetchSize)
fetchSize - the new default fetchSizepublic int getMaxRows()
public void setMaxRows(int maxRows)
maxRows - the max rows, 0 = no limit (default)public boolean isRemote()
public RemoteSession getRemoteSession()
getRemoteSession in interface Sessionpublic static int prepareRemoteDelegate(Class<?> clazz)
RemoteDelegate.
The delegates for the AbstractDbObject-classes "live" in the db, i.e. the remote session. Thus, delegates are unique per class AND db! In order for the AbstractDbObject-derived classes to quickly map to the corresponding delegate, the delegates get a unique handle, i.e. an index to an array of delegates, which in turn is unique among ALL sessions.
clazz - is the AbstractDbObject-classpublic org.tentackle.persist.rmi.RemoteDelegate getRemoteDelegate(int delegateId)
delegateId - is the handle for the delegatepublic org.tentackle.persist.rmi.RemoteDelegate createRemoteDelegate(String className) throws RemoteException
className - the classnameRemoteException - if creating the delegate failedpublic boolean isCountModificationAllowed()
public void setCountModificationAllowed(boolean countModificationAllowed)
countModificationAllowed - true if allowed, false if turned offpublic void setLogModificationAllowed(boolean logModificationAllowed)
logModificationAllowed - true to allow, false to denypublic boolean isLogModificationAllowed()
public void setLogModificationDeferred(boolean logModificationDeferred)
ModificationLogs are not written to the database.
Instead they are kept in memory and can be processed later via
popModificationLogsOfTransaction().
The state will be handed over to the remote db-connection as well.
Note: the deferred state will be reset to false after each begin/commit/rollback.
Important: if the deferred state is changed within a transaction and there are
already modifications made, i.e. modlogs were created, the deferred state will
*not* be changed! Furthermore, if the deferred state is changed to false.
the modlogs are removed from the database (but kept in memory).
As a consequence, the in-memory modlogs will always contain the whole transaction
or nothing. Only popModificationLogsOfTransaction() removes the logs
collected so far or the end of the transaction.
logModificationDeferred - true to defer logs for the rest of current transaction, false to undeferpublic boolean isLogModificationDeferred()
public void pushModificationLogOfTransaction(ModificationLog log)
ModificationLog to the list of modlogs of the current transaction.
Notice: only allowed for local databases!
log - the modlogpopModificationLogsOfTransaction()public List<ModificationLog> popModificationLogsOfTransaction()
ModificationLogs of the current transaction.
Upon return the list of logs is cleared.
Works for local and remote databases.
pushModificationLogOfTransaction(org.tentackle.persist.ModificationLog)public IdSource getDefaultIdSource()
IdSource.public void setDefaultIdSource(IdSource idSource)
IdSource.idSource - New value of property idSource.public long getLogModificationTxId()
public void setLogModificationTxId(long logModificationTxId)
logModificationTxId - the transaction IDpublic boolean isLogModificationTxEnabled()
public void setLogModificationTxEnabled(boolean logModificationTxEnabled)
ModificationLog
as well.logModificationTxEnabled - true to turn on transaction logging.public Backend getBackend()
public String getRemoteName()
Copyright © 2016 Krake Softwaretechnik. All rights reserved.