T - the PDO class (interface)P - the persistence implementation classpublic abstract class AbstractPersistentObject<T extends PersistentDomainObject<T>,P extends AbstractPersistentObject<T,P>> extends AbstractDbObject<P> implements PersistentObject<T>
AbstractDbObject with features necessary in nearly all
desktop enterprise applications.
In contrast to AbstractDbObject, which is associated to a Db,
an AbstractPersistentObject is associated to a DomainContext.
| Modifier and Type | Field and Description |
|---|---|
static String |
AN_EDITEDBY
name of the editedBy attribute.
|
static String |
AN_EDITEDEXPIRY
name of the editedExpiry attribute.
|
static String |
AN_EDITEDSINCE
name of the editedSince attribute.
|
static String |
AN_NORMTEXT
name of the normText attribute.
|
static String |
AN_ROOTCLASSID
name of rootclass-ID attribute.
|
static String |
AN_ROOTID
name of root-ID attribute.
|
static String |
CN_EDITEDBY
name of the editedBy column.
|
static String |
CN_EDITEDEXPIRY
name of the editedExpiry column.
|
static String |
CN_EDITEDSINCE
name of the editedSince column.
|
static String |
CN_NORMTEXT
name of the normText column.
|
static String |
CN_ROOTCLASSID
name of rootclass-ID column.
|
static String |
CN_ROOTID
name of root-ID column.
|
protected boolean |
objectIsSnapshot |
static String |
TX_DELETE_ALL_IN_CONTEXT
delete all in context
|
static String |
TX_SAVE_COPY_IN_CONTEXT
saveImpl copy in context
|
static String |
TX_TRANSFER_TOKENLOCK
transfer edited by
|
AN_CLASSID, AN_ID, AN_SERIAL, AN_TABLESERIAL, CN_CLASSID, CN_ID, CN_SERIAL, CN_TABLESERIAL, idComparator, nameComparator, nameIdComparator, preparePending, TX_DELETE_LIST, TX_DELETE_MISSING_IN_LIST, TX_DELETE_OBJECT, TX_DUMMY_UPDATE, TX_INSERT_OBJECT, TX_INSERT_PLAIN, TX_SAVE, TX_SAVE_LIST, TX_SYNC, TX_UPDATE_OBJECT, TX_UPDATE_PLAIN, TX_UPDATE_SERIAL, TX_UPDATE_SERIAL_AND_TABLESERIAL, TX_UPDATE_TABLESERIAL| Constructor and Description |
|---|
AbstractPersistentObject()
Creates an application database object without a database context.
|
AbstractPersistentObject(T pdo)
Creates an application database object without a database context.
|
AbstractPersistentObject(T pdo,
DomainContext context)
Creates an application database object.
|
AbstractPersistentObject(T pdo,
Session session)
Creates an application database object without a domain context
for a given connection.
|
| Modifier and Type | Method and Description |
|---|---|
int |
addComponents(IdentifiableMap<PersistentDomainObject<?>> components,
boolean onlyLoaded)
Adds the components of this object to a map.
|
int |
addComponents(IdentifiableMap<PersistentDomainObject<?>> components,
Collection<? extends PersistentDomainObject<?>> objects,
boolean onlyLoaded)
Adds the components of a collection to a map.
|
<T extends PersistentDomainObject<T>> |
addReferencingClass(Class<T> clazz,
String methodName)
Adds a PDO class that is referencing this PDO clazz.
|
protected void |
addSnapshot(T snapshot)
Adds a snapshot to the list of snapshots.
|
protected void |
assertDomainContextMutable()
Asserts that the domain context is mutable.
|
protected void |
assertMutable()
Asserts that object is mutable.
|
protected void |
assertNormTextProvided()
Asserts that entity provides a normtext.
|
void |
assertNotAbstract()
Asserts that this is not an abstract entity class.
|
protected void |
assertNotCached()
Asserts that the PDO is not cached.
|
protected void |
assertPersistable()
Asserts that this object is saveable.
|
protected void |
assertReadPermission()
Checks read permission for this object.
|
protected void |
assertRootContext()
Asserts that the po's context is a root context.
|
void |
assertRootContextIsAccepted()
Checks the root context agains the security rules.
|
void |
assertRootEntity()
Checks if the po is a root entity.
|
protected void |
assertTokenLockProvided()
Asserts that entity provides a normtext.
|
protected void |
assertValidSnapshot(T snapshot)
Asserts that given snapshot is valid for this object.
|
protected void |
assertWritePermission()
Checks write permission for this object.
|
void |
clearTokenLock()
Clears or renews the token lock.
|
P |
clone()
Clones an object.
|
PersistentObject<T> |
clonePersistentObject() |
void |
configureRemoteObject(DomainContext context,
T obj)
Configures the remotely retrieved object.
|
void |
configureRemoteObjects(DomainContext context,
Collection<T> objects)
Configures the remotely retrieved objects.
|
boolean |
containsPattern(String pattern)
Searches for a "pattern" in this object.
The default implementation looks for the pattern in the normtext. |
T |
copy()
Creates a "fast copy" of this object.
|
long |
countModification()
Counts a modification for the class of this object.
|
protected void |
createAttributesInSnapshot(AbstractPersistentObject snapshot)
Updates the attributes in snapshot object.
The snapshot object is assumed to be a clone of this object. |
protected void |
createComponentsInSnapshot(AbstractPersistentObject snapshot)
Updates the components in snapshot object.
The snapshot object is assumed to be a clone of this object. |
T |
createCopyInContext(DomainContext otherContext)
Creates a new object as a copy of the current object in another
(or the same) database context.
The new context must be of the same class as the old one. |
String |
createDummyUpdateSql()
Creates the SQL code for the dummy update statement.
Useful get an exclusive lock within a transaction. |
StringBuilder |
createSelectAllByIdInnerSql()
Creates the inner sql text to select all fields by ID.
|
StringBuilder |
createSelectAllIdSerialInnerSql()
Creates the inner sql text to select the id and serial fields.
|
StringBuilder |
createSelectAllInnerSql()
Creates the inner sql text to select all fields.
|
String |
createSelectAllSql()
Creates SQL code for select all.
Appends context condition and order by clause if configured. |
String |
createSelectByNormTextSql()
Creates the SQL code for select by normtext.
|
String |
createSelectExpiredTableSerials1Sql()
Creates the SQL code for the first statement to select expired table serials.
|
String |
createSelectExpiredTableSerials2Sql()
Creates the SQL code for the second statement to select expired table serials.
|
StringBuilder |
createSelectIdInnerSql()
Creates the inner sql text to select the ID field.
|
StringBuilder |
createSelectIdInnerSql(PersistentObjectClassVariables<? super T,? super P> classVariables)
Creates the inner sql text to select the ID field.
|
String |
createSelectMaxIdSql()
Creates the SQL code for the selectMaxId statement.
|
String |
createSelectMaxTableSerialSql()
Creates the SQL code for the selectMaxTableSerial statement.
|
String |
createSelectSerialSql()
Creates the SQL code for the selectSerial statement.
|
String |
createSelectTokenLockSql()
Creates the SQL code for the select in
updateTokenLock(org.tentackle.common.Timestamp, long, org.tentackle.common.Timestamp) statement. |
T |
createSnapshot()
Creates a snapshot of this object.
|
String |
createTransferTokenLockSql()
Creates the SQL code for the
transferTokenLock(long) statement without tableserial. |
String |
createTransferTokenLockWithTableSerialSql()
Creates the SQL code for the
transferTokenLock(long) statement with tableserial. |
String |
createUpdateSerialAndTableSerialSql()
Creates the SQL code for the serial + tableSerial update statement.
|
String |
createUpdateSerialSql()
Creates the SQL code for the serial update statement.
|
String |
createUpdateTokenLockOnlySql()
Creates the SQL code for the
updateTokenLockOnly() statement. |
String |
createUpdateTokenLockSql()
Creates the SQL code for the
updateTokenLock(org.tentackle.common.Timestamp, long, org.tentackle.common.Timestamp) statement. |
String |
createUpdateTokenLockWithCountSql()
Creates the SQL code for the
updateTokenLock(org.tentackle.common.Timestamp, long, org.tentackle.common.Timestamp) statement with mod counting. |
DomainContext |
createValidContext() |
void |
delete() |
protected <X extends PersistentDomainObject<X>> |
delete(Collection<X> pdos)
Deletes a List of objects.
This method is provided to mark components in PDOs only. |
protected void |
delete(PersistentDomainObject<?> pdo)
Deletes a PDO.
This method is provided to save components in PDOs only. |
protected void |
deleteImpl()
Implementation of delete bypassing the invocation handler.
|
protected <X extends PersistentDomainObject<X>> |
deleteMissingInCollection(Collection<X> oldCollection,
Collection<X> newCollection)
Deletes all objects in oldList that are not in newList.
This method is provided to save components in PDOs only. |
void |
deletePlainWithComponents()
Deletes this object and all its components without any further processing.
Same as AbstractDbObject.deletePlain() but with components. |
int |
deletePlainWithComponents(Collection<? extends PersistentDomainObject<?>> objects)
Deletes plain with components all objects of a collection.
|
T |
derivePdoFromPo(T pdo,
P po)
Derive the concrete PDO from a given PO.
|
void |
determineContextId() |
T |
executeFirstPdoQuery(PreparedStatementWrapper st)
Executes a query for a prepared statement and returns the first PDO.
|
T |
executeFirstPdoQuery(PreparedStatementWrapper st,
JoinedSelect<T> js)
Executes a query for a prepared statement and returns the first PDO.
|
List<T> |
executeListQuery(PreparedStatementWrapper st)
Executes the query for a prepared statement and returns the results in a list.
|
List<T> |
executeListQuery(PreparedStatementWrapper st,
JoinedSelect<T> js)
Executes the query for a prepared statement and returns the results in a list.
|
void |
executeQueryToList(PreparedStatementWrapper st,
JoinedSelect<T> js,
List<T> list)
Executes the query for a prepared statement and adds the results to a list.
|
void |
executeQueryToList(ResultSetWrapper rs,
JoinedSelect<T> js,
List<T> list)
Executes the query for a prepared statement and adds the results to a list.
|
TrackedList<T> |
executeTrackedListQuery(PreparedStatementWrapper st)
Executes the query for a prepared statement and returns the results in a tracked list.
|
TrackedList<T> |
executeTrackedListQuery(PreparedStatementWrapper st,
JoinedSelect<T> js)
Executes the query for a prepared statement and returns the results in a tracked list.
|
boolean |
expireCache(long maxSerial)
Expires the cache according to the serial numbers.
If objects of this class are cached, the cache must be expired on updates, etc... |
T |
findDuplicate()
Checks whether this object (if saved) would violate any
unique constraints.
|
protected Method |
findSnapshotMethod(String methodName,
Class<?> clazz)
Finds a snapshot method.
Snapshot methods ( createAttributesInSnapshot(org.tentackle.pdo.AbstractPersistentObject), createComponentsInSnapshot(org.tentackle.pdo.AbstractPersistentObject),
revertAttributesToSnapshot(org.tentackle.pdo.AbstractPersistentObject) and revertComponentsToSnapshot(org.tentackle.pdo.AbstractPersistentObject)) take the snapshot
object with the correct implementation type and are implemented at some implementation class. |
void |
finishModification(char modType)
Does any postprocessing after delete, insert or update.
|
void |
finishNotUpdated(char modType)
Does any update postprocessing for objects not being updated (because not modified
for some reason, e.g.
|
DomainContext |
getBaseContext() |
PdoCache<T> |
getCache()
Gets the cache.
|
long |
getCacheAccessCount()
Gets the cache access count.
|
long |
getCacheAccessTime()
Gets the last cache access time.
|
PersistentObjectClassVariables<T,P> |
getClassVariables()
Gets the application oriented class variables for this object.
Class variables for classes derived from AbstractPersistentObject are kept in an instance of PersistentObjectClassVariables. |
String |
getColumnName(String name)
Gets the full column name with optional table alias.
|
long |
getContextId() |
long |
getContextUserId()
Gets the user id from the current context, i.e.
|
T |
getCopiedObject()
Gets the original object if this object was created by
createCopyInContext(org.tentackle.pdo.DomainContext). |
Class<? extends ValidationScope>[] |
getDefaultScopes() |
DomainContext |
getDomainContext() |
DomainDelegate<T> |
getDomainDelegate() |
JoinedSelect<T> |
getEagerJoinedSelect()
Adds the eager joins to the created SQL.
|
List<Join<? super T,?>> |
getEagerJoins()
Returns the eager joins for this PDO.
|
long |
getEditedBy()
Gets the id of the user currently editing this object.
|
org.tentackle.common.Timestamp |
getEditedExpiry()
Gets the time since when this object is being edited.
|
org.tentackle.common.Timestamp |
getEditedSince()
Gets the time since when this object is being edited.
|
String |
getNormText()
Gets the normtext.
|
T |
getPdo() |
Class<T> |
getPdoClass()
Gets the pdo-class.
|
<T extends PersistentDomainObject<T>> |
getPersistenceClass(Class<T> clazz)
Gets the persistence class from a pdo class.
|
org.tentackle.pdo.rmi.AbstractPersistentObjectRemoteDelegate<T,P> |
getRemoteDelegate()
Gets the delegate for remote connections.
Each class has its own delegate. |
int |
getRootClassId() |
long |
getRootId() |
SecurityResult |
getSecurityResult(Permission permission) |
List<T> |
getSnapshots()
Gets all snapshots.
|
String |
getSqlClassIdCondition()
Gets the additional condition to be used in the WHERE clause for the classid.
|
String |
getSqlContextCondition()
Gets the SQL code for the context condition.
|
String |
getTableAlias()
Gets the table alias.
|
String |
getTableName()
Gets the database table name for the class of this object.
|
<U extends PersistentDomainObject<U>> |
getTokenLockObject()
Gets the object associated to the id of the editedBy-attribute.
This is usually the id of a persistent Object implementing the concept of a user, group, role or whatever. |
long |
getTokenLockTimeout()
Gets the expiration in milliseconds of the "being-edited-token" if
this object should request such a token when being edited.
|
String |
getTopSuperTableAlias()
Gets the alias for the topmost super class.
|
String |
getTopSuperTableName()
Gets the tablename for the topmost super class.
|
Object |
getTransientData()
Gets the optional transient data object.
The default implementation does nothing. |
int |
getValidClassId()
Gets the classid.
|
void |
initModification(char modType)
Does any preprocessing before delete, insert or update.
|
void |
insertObject()
Inserts this (new) object into the database.
|
void |
insertPlainWithComponents()
Inserts this object and all its components without any further processing.
Same as AbstractDbObject.insertPlain() but with components. |
int |
insertPlainWithComponents(Collection<? extends PersistentDomainObject<?>> objects)
Inserts plain with components all objects of a collection.
|
boolean |
isAbstract()
Returns whether this an abstract PDO.
Abstract PDOs are real objects but cannot be persisted. |
boolean |
isCacheable()
Determines whether object is cacheable or not.
|
boolean |
isCached() |
boolean |
isClassIdRequiredInWhereClause()
Returns whether the classid needs to be inluded in the WHERE-clause.
Applies only to leafs with SINGLE inheritance. |
boolean |
isComposite()
Tells whether this object is composite (i.e.
|
boolean |
isCountingModificationForTokenLock() |
boolean |
isDomainContextImmutable()
Returns whether the domain context is immutable.
|
boolean |
isEditAllowed() |
boolean |
isExpired()
Checks whether object has been marked expired.
|
boolean |
isExplicitIdAliasRequiredInJoins()
Returns whether an explicit id alias is necessary in joins.
This applies to MULTI-table inherited PDOs only (abstracts and leafs). |
protected <X extends PersistentDomainObject<X>> |
isModified(Collection<X> pdos)
Checks whether some of the objects in the list are modified.
This method is provided to save components in PDOs only. |
boolean |
isNormTextProvided() |
boolean |
isPermissionAccepted(Permission permission) |
boolean |
isPersistable()
Determines whether this object is allowed to be stored in DB.
By default all mutable objects are allowed to be saved. |
boolean |
isReadAllowed()
Determines whether the application is allowed to read this PDO.
Makes no sense to publish in PersistentObject because PDOs without read permissions are not read from the database at all. |
boolean |
isReferenced()
Checks whether this object is referenced by other objects.
|
boolean |
isRenewTokenLockRequested()
Determines whether to renew the token lock on saveImpl or update.
|
boolean |
isRootClassIdProvided() |
boolean |
isRootEntity() |
boolean |
isRootIdProvided() |
boolean |
isSnapshot()
Returns whether this is a snapshot.
|
boolean |
isTokenLocked()
Checks whether this object is token locked (editedBy != 0) and
the lock is not expired.
|
boolean |
isTokenLockedBy(long userId)
Checks whether this object is edited locked by given user.
|
boolean |
isTokenLockedByMe()
Checks whether this object is edited locked by the current user.
|
boolean |
isTokenLockProvided()
By default objects don't need to include the editedBy/Since/Expiry columns in the
database table.
|
protected boolean |
isUpdateNecessary()
Returns whether update of this object is necessary.
|
boolean |
isUpdatingSerialEvenIfNotModified()
Determines whether in updates of composite objects unmodified objects in the
update path get at least the serial updated or are not touched at all.
|
boolean |
isValidated() |
boolean |
isViewAllowed() |
boolean |
isWriteAllowed() |
IdentifiableMap<? extends PersistentDomainObject<?>> |
loadComponents(boolean onlyLoaded)
Loads all components.
The method is used to transfer a copy of an object between tiers including all composite object relations recursively. |
void |
markCacheAccess()
mark cache access (count and set current system-time)
|
protected <X extends PersistentDomainObject<X>> |
markDeleted(Collection<X> pdos)
Marks all objects in a list to be deleted.
This method is provided to mark components in PDOs only. |
protected void |
markDeleted(PersistentDomainObject<?> pdo)
Marks an object to be deleted.
This method is provided to mark components in PDOs only. |
void |
newId()
Obtains a new ID for this object.
|
String |
orderBy()
Gets the natural ordering to be added in WHERE-clauses following "ORDER BY ".
|
T |
pdo() |
T |
persist() |
protected T |
persistImpl()
Implementation of persist bypassing the invocation handler.
|
T |
persistTokenLocked() |
P |
readFromResultSetWrapper(ResultSetWrapper rs)
Reads the values from a result-set into this object.
|
void |
readJoinedRow(ResultSetWrapper rs,
JoinedSelect<T> js)
Reads the next row from a result set within a joined select.
|
void |
releaseTokenLock()
Releases an edited by lock.
Use this method if a PDO needs to be unlocked without being persisted. |
T |
reload()
Reloads the object.
|
T |
reloadLocked()
Reloads the object with a write lock.
|
<T extends PersistentDomainObject<T>> |
removeReferencingClass(Class<T> clazz,
String methodName)
Removes a PDO class that is referencing this PDO clazz.
|
void |
requestTokenLock()
Requests an edited by lock.
|
ResultSetWrapper |
resultAll(JoinedSelect<T> js)
Gets the result set for all objects in the current context
for use in lists.
|
ResultSetWrapper |
resultAllCursor(JoinedSelect<T> js)
Gets the result set for all objects in the current context
for use in cursors.
Cursors differ from lists because they need ResultSet.TYPE_SCROLL_INSENSITIVE set. |
ResultSetWrapper |
resultByNormText(String normText,
JoinedSelect<T> js)
Gets the result set for the normtext query (where normtext like ?)
for use in lists.
If the given normtext is null or just "%" the method falls back to resultAll(org.tentackle.pdo.JoinedSelect<T>). |
ResultSetWrapper |
resultByNormTextCursor(String normText,
JoinedSelect<T> js)
Gets the result set for the normtext query (where normtext like ?)
for use in cursors.
Cursors differ from lists because they need ResultSet.TYPE_SCROLL_INSENSITIVE
set. |
protected void |
revertAttributesToSnapshot(AbstractPersistentObject snapshot)
Copies all attributes from a snapshot object back to this object.
|
protected void |
revertComponentsToSnapshot(AbstractPersistentObject snapshot)
Reverts all components of this object to a given snapshot.
|
void |
revertToSnapshot(T snapshot)
Reverts the state of this object to given snapshot.
|
void |
save() |
protected <X extends PersistentDomainObject<X>> |
save(Collection<X> pdos,
boolean modifiedOnly)
Saves a list of PDOs.
This method is provided to save components in PDOs only. |
protected void |
save(PersistentDomainObject<?> pdo)
Saves a PDO.
This method is provided to save components in PDOs only. |
T |
saveCopyInContext(DomainContext otherContext)
Same as
createCopyInContext(org.tentackle.pdo.DomainContext) but saves the new object within a transaction. |
protected void |
saveImpl()
Implementation of save bypassing the invocation handler.
|
T |
select(long id)
Loads a PDO from the database by its unique ID.
|
T |
select(long id,
boolean locked)
Loads a PDO from the database by its unique ID.
|
List<T> |
selectAll()
Selects all records in current context as a list.
|
ScrollableResource<T> |
selectAllAsCursor()
Selects all records in current context as a cursor
|
List<T> |
selectAllCached()
Gets all objects in context via cache.
|
List<T> |
selectAllForCache() |
List<T> |
selectByNormText(String normText)
Selects all objects with a given normtext as a list.
|
ScrollableResource<T> |
selectByNormTextAsCursor(String normText)
Selects all objects with a given normtext as a cursor.
|
T |
selectByTemplate(AbstractPersistentObject<T,P> template)
Selects an object according to a template object.
|
T |
selectCached(long id)
Gets the object via cache.
If there is no cache (i.e. |
T |
selectCachedOnly(long id)
Gets the object via cache only.
If there is no cache (i.e. |
T |
selectForCache(long id) |
T |
selectLocked(long id)
Loads and write-locks a PDO from the database by its unique ID.
|
void |
setDomainContext(DomainContext context) |
void |
setDomainContextImmutable(boolean contextImmutable)
Sets the immutable flag of the domain context.
|
void |
setEditedBy(long editedBy)
Sets the user editing this object.
Does *NOT* alter isModified() and does not require the object to be mutable. |
void |
setEditedExpiry(org.tentackle.common.Timestamp editedExpiry)
Sets the time when the token should expire.
Does *NOT* alter isModified() and does not require the object to be mutable. |
void |
setEditedSince(org.tentackle.common.Timestamp editedSince)
Sets the time since when this object is being edited.
Does *NOT* alter isModified() and does not require the object to be mutable. |
void |
setExpired(boolean expired)
Sets this object's expiration flag.
|
void |
setModified(boolean modified)
Sets the modified flag.
|
void |
setNormText(String normText)
Sets the normtext.
|
void |
setPdo(T pdo) |
void |
setPersistable(boolean persistable)
Sets the local persistable flag.
|
void |
setRenewTokenLockRequested(boolean renewTokenLock)
Sets whether to apply or renew the token lock on insert or update.
|
void |
setRootClassId(int rootClassId) |
void |
setRootId(long rootId) |
<U extends PersistentDomainObject<U>> |
setTokenLockObject(U obj)
Sets the user/group/role-object editing this object.
|
void |
setTransientData(Object data)
Sets the optional transient data object.
Sometimes, e.g. |
T |
transferTokenLock(long userId) |
void |
updateObject()
Updates this object to the database.
The modified attribute gets cleared if insert was successful. |
boolean |
updateRootContext()
Updates the root context.
Method is used after deserialization. |
void |
updateTokenLock(org.tentackle.common.Timestamp tokenExpiry)
Updates editing info in db-record (if feature enabled).
Will *NOT* log modification and *NOT* update the serial-counter! Must be called from within application where appropriate. |
void |
updateTokenLock(org.tentackle.common.Timestamp tokenExpiry,
long userId,
org.tentackle.common.Timestamp curTime)
Updates token lock columns in db-record.
Will *NOT* log modification and *NOT* update the serial-counter! Must be called from within application where appropriate. |
void |
updateTokenLockOnly()
Update the editedBy-attributes to persistent storage.
No check is done whether locked or not and there is no serial update and no modlog. |
void |
validate() |
List<ValidationResult> |
validate(String validationPath,
ValidationScope scope) |
acceptPersistenceVisitor, addPropertyChangeListener, addPropertyChangeListener, assertNotNew, assertNotOverloaded, assertNotRemote, assertNumberOfRowsAffected, assertRemote, assertThisRowAffected, attributesModified, beginTx, clearOnRemoteSave, compareTo, copyToDb, createAttributesInSnapshot, createDeleteAllSql, createDeleteSql, createInsertSql, createModificationLog, createPreparedStatement, createPreparedStatement, createSelectSql, createSqlUpdate, createUpdateSql, deleteImpl, deleteObject, deletePlain, deleteReferencedRelations, deleteReferencingRelations, differsPersisted, dummyUpdate, equals, firePropertyChange, getBackend, getClassBaseName, getClassId, getColumnCount, getExpirationBacklog, getExpiredTableSerials, getFields, getId, getIdSource, getImmutableLoggingLevel, getModificationCount, getModificationLog, getPreparedStatement, getPreparedStatement, getPropertyChangeListeners, getPropertyChangeListeners, getSerial, getSession, getSessionHolder, getTableSerial, hashCode, insertImpl, insertPlain, isCountingModification, isDeleted, isEntity, isIdValid, isImmutable, isLoggingModification, isModified, isNew, isOverloadable, isRemovable, isSessionImmutable, isStatementAlwaysPrepared, isTableSerialProvided, isTracked, isVirgin, loadLazyReferences, logModification, markDeleted, newInstance, newInstance, newInstance, persistObject, prepareDelete, prepareSave, prepareSetFields, reloadLockedObject, reloadObject, removeAllPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener, reserveId, resultAllIdSerial, resultAllObjects, revertAttributesToSnapshot, saveObject, saveReferencedRelations, saveReferencingRelations, selectAllIdSerial, selectAllObjects, selectExpiredTableSerials, selectExpiredTableSerials, selectLockedObject, selectMaxId, selectMaxTableSerial, selectNextObject, selectObject, selectSerial, setClassId, setFields, setId, setImmutable, setImmutableLoggingLevel, setModificationLog, setOverloadable, setSerial, setSession, setSessionHolder, setSessionImmutable, setStatementAlwaysPrepared, setTableSerial, toGenericString, toIdString, toString, unmarkDeleted, updateImpl, updatePlain, updateSerial, updateSerialAndTableSerialfinalize, getClass, notify, notifyAll, wait, wait, waitattributesModified, differsPersisted, getClassBaseName, getClassId, getExpiredTableSerials, getId, getModificationCount, getSerial, getTableSerial, isDeleted, isImmutable, isNew, isRemovable, isTableSerialProvided, isTracked, prepareDelete, reserveId, selectAllIdSerial, selectExpiredTableSerials, selectExpiredTableSerials, selectMaxId, selectMaxTableSerial, selectSerial, setId, setImmutable, setSerial, setTableSerial, toIdStringtoGenericStringisModifiedisVirginon, opnisSessionImmutable, setSession, setSessionImmutablegetSessionprotected transient boolean objectIsSnapshot
public static final String CN_EDITEDBY
public static final String AN_EDITEDBY
public static final String CN_EDITEDEXPIRY
public static final String AN_EDITEDEXPIRY
public static final String CN_EDITEDSINCE
public static final String AN_EDITEDSINCE
public static final String CN_NORMTEXT
public static final String AN_NORMTEXT
public static final String CN_ROOTID
public static final String AN_ROOTID
public static final String CN_ROOTCLASSID
public static final String AN_ROOTCLASSID
public static final String TX_SAVE_COPY_IN_CONTEXT
public static final String TX_DELETE_ALL_IN_CONTEXT
public static final String TX_TRANSFER_TOKENLOCK
public AbstractPersistentObject(T pdo, DomainContext context)
pdo - the persistent domain object this is a delegate forcontext - the database contextpublic AbstractPersistentObject(T pdo, Session session)
Note: the application must set the context.
pdo - the persistent domain object this is a delegate forsession - the session (must be an instance of Session).public AbstractPersistentObject(T pdo)
Note: the application must set the context.
pdo - the persistent domain object this is a delegate forpublic AbstractPersistentObject()
public DomainDelegate<T> getDomainDelegate()
getDomainDelegate in interface PersistenceDelegate<T extends PersistentDomainObject<T>>public T getPdo()
getPdo in interface PdoHolder<T extends PersistentDomainObject<T>>public T pdo()
pdo in interface PersistentObject<T extends PersistentDomainObject<T>>public void setPdo(T pdo)
setPdo in interface PdoHolder<T extends PersistentDomainObject<T>>public P clone()
AbstractDbObject
Cloning an object yields a copy with id=0 and serial=0.
Needs to be overridden if object references, etc... have to be cloned too.
Subclasses should throw a PersistenceException if they should not be cloned
depending on the application logic (not CloneNotSupportedException).
clone in class AbstractDbObject<P extends AbstractPersistentObject<T,P>>public PersistentObject<T> clonePersistentObject()
clonePersistentObject in interface PersistentObject<T extends PersistentDomainObject<T>>protected Method findSnapshotMethod(String methodName, Class<?> clazz) throws NoSuchMethodException
createAttributesInSnapshot(org.tentackle.pdo.AbstractPersistentObject), createComponentsInSnapshot(org.tentackle.pdo.AbstractPersistentObject),
revertAttributesToSnapshot(org.tentackle.pdo.AbstractPersistentObject) and revertComponentsToSnapshot(org.tentackle.pdo.AbstractPersistentObject)) take the snapshot
object with the correct implementation type and are implemented at some implementation class.
This method finds the most specific snapshot-method along the inheritance hierarchy.methodName - the snapshot method nameclazz - the implementation classNoSuchMethodException - if no such method foundpublic T createSnapshot()
The method must be implemented. The default implementation just throws PersistenceException.
createSnapshot in interface Snapshotable<T extends PersistentDomainObject<T>>protected void createAttributesInSnapshot(AbstractPersistentObject snapshot)
snapshot - the snapshotprotected void createComponentsInSnapshot(AbstractPersistentObject snapshot)
snapshot - the snapshotpublic void revertToSnapshot(T snapshot)
The method must be implemented. The default implementation just throws PersistenceException.
revertToSnapshot in interface Snapshotable<T extends PersistentDomainObject<T>>snapshot - the snapshot to revert toprotected void revertAttributesToSnapshot(AbstractPersistentObject snapshot)
snapshot - the snapshot objectprotected void revertComponentsToSnapshot(AbstractPersistentObject snapshot)
snapshot - the snapshot objectpublic boolean isSnapshot()
isSnapshot in interface Snapshotable<T extends PersistentDomainObject<T>>public List<T> getSnapshots()
getSnapshots in interface Snapshotable<T extends PersistentDomainObject<T>>protected void addSnapshot(T snapshot)
snapshot - the snapshot to addprotected void assertValidSnapshot(T snapshot)
snapshot - the snapshotprotected void assertNotCached()
protected void assertMutable()
Overridden due to snapshots are immutable.
assertMutable in class AbstractDbObject<P extends AbstractPersistentObject<T,P>>public boolean isPersistable()
AbstractDbObjectisPersistable in interface PersistentObject<T extends PersistentDomainObject<T>>isPersistable in class AbstractDbObject<P extends AbstractPersistentObject<T,P>>public void setPersistable(boolean persistable)
The implementation maintains an additional flag to disable persistabilty.
persistable - true if persistable, false if not persistableprotected void assertPersistable()
Overridden to check assertMutable().
assertPersistable in class AbstractDbObject<P extends AbstractPersistentObject<T,P>>public boolean isRootEntity()
The default is false. Override if this is a root-entity.
isRootEntity in interface PersistentObject<T extends PersistentDomainObject<T>>public boolean isRootIdProvided()
isRootIdProvided in interface PersistentObject<T extends PersistentDomainObject<T>>public long getRootId()
getRootId in interface PersistentObject<T extends PersistentDomainObject<T>>public void setRootId(long rootId)
setRootId in interface PersistentObject<T extends PersistentDomainObject<T>>public boolean isRootClassIdProvided()
isRootClassIdProvided in interface PersistentObject<T extends PersistentDomainObject<T>>public int getRootClassId()
getRootClassId in interface PersistentObject<T extends PersistentDomainObject<T>>public void setRootClassId(int rootClassId)
setRootClassId in interface PersistentObject<T extends PersistentDomainObject<T>>public boolean isNormTextProvided()
isNormTextProvided in interface PersistentObject<T extends PersistentDomainObject<T>>protected void assertNormTextProvided()
public void setNormText(String normText)
setNormText in interface PersistentObject<T extends PersistentDomainObject<T>>normText - the normtextpublic String getNormText()
getNormText in interface PersistentObject<T extends PersistentDomainObject<T>>public boolean isDomainContextImmutable()
isDomainContextImmutable in interface DomainContextDependablepublic void setDomainContextImmutable(boolean contextImmutable)
setDomainContextImmutable in interface DomainContextDependablecontextImmutable - true if context cannot be changedprotected void assertDomainContextMutable()
public void setDomainContext(DomainContext context)
Setting the context will also set the session and context id.
setDomainContext in interface DomainContextDependablepublic DomainContext getDomainContext()
The default implementation just returns the context. Subclasses may override this with a covariant method.
getDomainContext in interface DomainContextProviderpublic void determineContextId()
The default implementation does nothing (object living in a context not depending on another object).
determineContextId in interface DomainContextDependablepublic long getContextId()
The default implementation returns -1.
getContextId in interface DomainContextDependablepublic String getSqlContextCondition()
public String getSqlClassIdCondition()
Example: return " AND " + CN_CLASSID + "=?";
public DomainContext getBaseContext()
The default implementation returns the PDO's DomainContext.
getBaseContext in interface DomainContextDependablepublic DomainContext createValidContext()
The default implementation just returns a new DomainContext.
createValidContext in interface DomainContextDependablepublic PersistentObjectClassVariables<T,P> getClassVariables()
PersistentObjectClassVariables.getClassVariables in class AbstractDbObject<P extends AbstractPersistentObject<T,P>>AbstractDbObject.getClassVariables()public String getTableName()
AbstractDbObjectgetTableName in interface PersistentObject<T extends PersistentDomainObject<T>>getTableName in class AbstractDbObject<P extends AbstractPersistentObject<T,P>>public String getTableAlias()
public String getColumnName(String name)
name - the short namepublic String getTopSuperTableAlias()
public String getTopSuperTableName()
public Class<T> getPdoClass()
public boolean isAbstract()
isAbstract in interface PersistentObject<T extends PersistentDomainObject<T>>public void assertNotAbstract()
public int getValidClassId()
PersistenceException - if not validpublic boolean isClassIdRequiredInWhereClause()
public boolean isExplicitIdAliasRequiredInJoins()
public boolean isComposite()
isComposite in interface PersistentObject<T extends PersistentDomainObject<T>>public IdentifiableMap<? extends PersistentDomainObject<?>> loadComponents(boolean onlyLoaded)
onlyLoaded - true if return only already loaded components (lazy composite relations)public int addComponents(IdentifiableMap<PersistentDomainObject<?>> components, boolean onlyLoaded)
components - the component maponlyLoaded - true if return only already loaded component (lazy composite relations)public int addComponents(IdentifiableMap<PersistentDomainObject<?>> components, Collection<? extends PersistentDomainObject<?>> objects, boolean onlyLoaded)
components - the components mapobjects - the collection of objects to add along with their componentsonlyLoaded - true if return only already loaded components (lazy composite relations)public void deletePlainWithComponents()
AbstractDbObject.deletePlain() but with components.public int deletePlainWithComponents(Collection<? extends PersistentDomainObject<?>> objects)
objects - the collection of PDOspublic void insertPlainWithComponents()
AbstractDbObject.insertPlain() but with components.public int insertPlainWithComponents(Collection<? extends PersistentDomainObject<?>> objects)
objects - the collection of PDOspublic T findDuplicate()
The method is usually used by the presentation layer
to check for duplicates.
The default implementation invokes findByUniqueDomainKey(getUniqueDomainKey())
and throws UnsupportedOperationException if one of those methods are not implemented
(which is the default).
findDuplicate in interface PersistentObject<T extends PersistentDomainObject<T>>public boolean isCacheable()
isCacheable in interface PersistentObject<T extends PersistentDomainObject<T>>public boolean isExpired()
isExpired in interface PersistentObject<T extends PersistentDomainObject<T>>public void setExpired(boolean expired)
setExpired in interface PersistentObject<T extends PersistentDomainObject<T>>expired - true if object is expiredpublic long getCacheAccessTime()
getCacheAccessTime in interface PersistentObject<T extends PersistentDomainObject<T>>public long getCacheAccessCount()
getCacheAccessCount in interface PersistentObject<T extends PersistentDomainObject<T>>public void markCacheAccess()
markCacheAccess in interface PersistentObject<T extends PersistentDomainObject<T>>public boolean isCached()
isCached in interface PersistentObject<T extends PersistentDomainObject<T>>public SecurityResult getSecurityResult(Permission permission)
getSecurityResult in interface PersistentObject<T extends PersistentDomainObject<T>>public boolean isPermissionAccepted(Permission permission)
isPermissionAccepted in interface PersistentObject<T extends PersistentDomainObject<T>>public T createCopyInContext(DomainContext otherContext)
getCopiedObject()).createCopyInContext in interface PersistentObject<T extends PersistentDomainObject<T>>otherContext - the database contextpublic T getCopiedObject()
createCopyInContext(org.tentackle.pdo.DomainContext).getCopiedObject in interface PersistentObject<T extends PersistentDomainObject<T>>public T saveCopyInContext(DomainContext otherContext)
createCopyInContext(org.tentackle.pdo.DomainContext) but saves the new object within a transaction.otherContext - the other domain contextpublic T selectByTemplate(AbstractPersistentObject<T,P> template)
template - the template objectpublic T copy()
The method is provided as a fast alternative to deep cloning via reflection or serialization.
All database-attributes are copied in such a way that each attribute of the new object can be changed without modifying the state of the original object. This also applies to all related perstent objects along the object graph. Non-persistent objects or any other non-database attributes are initialized according to the object's constructor (i.e. will usually be initialized to false, 0 or null, respectively).
The method will createPdo a new object (no clonePdo!) and set all attributes the same way as if the object has been loaded from storage.
Notice that it differs semantically from createCopyInContext() as copy() will copy the identity (ID) from the source object as well and will retain the context. Thus, upon return we're talking about another instance of the "same" object with respect to what the database considers as "same".
A copied object is always not modified and not deleted, as it is when loaded from the database.
The default implementation throws a PersistenceException, i.e. the method must be overridden. See the PdoCopy wurblet for an implementation.
public JoinedSelect<T> getEagerJoinedSelect()
public P readFromResultSetWrapper(ResultSetWrapper rs)
Overridden to implement inheritance and adjust the domain context.
readFromResultSetWrapper in class AbstractDbObject<P extends AbstractPersistentObject<T,P>>rs - is the result set (wrapper)public void executeQueryToList(PreparedStatementWrapper st, JoinedSelect<T> js, List<T> list)
st - the query statementjs - the joined select configuration, null if no joinslist - the listpublic void executeQueryToList(ResultSetWrapper rs, JoinedSelect<T> js, List<T> list)
rs - the result set wrapperjs - the joined select configuration, null if no joinslist - the listpublic List<T> executeListQuery(PreparedStatementWrapper st, JoinedSelect<T> js)
st - the query statementjs - the joined select configuration, null if no joinspublic List<T> executeListQuery(PreparedStatementWrapper st)
st - the query statementpublic TrackedList<T> executeTrackedListQuery(PreparedStatementWrapper st, JoinedSelect<T> js)
st - the query statementjs - the joined select configuration, null if no joinspublic TrackedList<T> executeTrackedListQuery(PreparedStatementWrapper st)
st - the query statementpublic List<Join<? super T,?>> getEagerJoins()
public void readJoinedRow(ResultSetWrapper rs, JoinedSelect<T> js)
js - the joined selectrs - the result setpublic T executeFirstPdoQuery(PreparedStatementWrapper st, JoinedSelect<T> js)
st - the query statementjs - the joined select configuration, null if no joinspublic T executeFirstPdoQuery(PreparedStatementWrapper st)
st - the query statementpublic T select(long id, boolean locked)
id - is the object idlocked - true if select FOR UPDATEpublic T select(long id)
select in interface PersistentObject<T extends PersistentDomainObject<T>>id - is the object idpublic T reload()
Note: to make sure that any lazy inits are cleared, the returned object is always a new object.
reload in interface PersistentObject<T extends PersistentDomainObject<T>>public T reloadLocked()
reloadLocked in interface PersistentObject<T extends PersistentDomainObject<T>>public T selectLocked(long id)
selectLocked in interface PersistentObject<T extends PersistentDomainObject<T>>id - is the object idpublic T derivePdoFromPo(T pdo, P po)
pdo - the original persistent domain objectpo - the effective persistent object from readFromResultSetWrapperpublic void assertRootContextIsAccepted()
public StringBuilder createSelectAllInnerSql()
AbstractDbObjectReturns something like:
"* FROM xytable WHERE 1=1"
createSelectAllInnerSql in class AbstractDbObject<P extends AbstractPersistentObject<T,P>>public StringBuilder createSelectAllIdSerialInnerSql()
AbstractDbObjectReturns something like:
"id,serial FROM xytable WHERE 1=1"
createSelectAllIdSerialInnerSql in class AbstractDbObject<P extends AbstractPersistentObject<T,P>>public StringBuilder createSelectAllByIdInnerSql()
AbstractDbObjectReturns something like:
"* FROM xytable WHERE id=?"
createSelectAllByIdInnerSql in class AbstractDbObject<P extends AbstractPersistentObject<T,P>>public StringBuilder createSelectIdInnerSql(PersistentObjectClassVariables<? super T,? super P> classVariables)
Returns something like:
"id FROM xytable WHERE 1=1"
classVariables - the classvariablespublic StringBuilder createSelectIdInnerSql()
AbstractDbObjectReturns something like:
"id FROM xytable WHERE 1=1"
createSelectIdInnerSql in class AbstractDbObject<P extends AbstractPersistentObject<T,P>>public String createSelectByNormTextSql()
public String createSelectSerialSql()
createSelectSerialSql in class AbstractDbObject<P extends AbstractPersistentObject<T,P>>public String createSelectMaxIdSql()
createSelectMaxIdSql in class AbstractDbObject<P extends AbstractPersistentObject<T,P>>public String createSelectMaxTableSerialSql()
createSelectMaxTableSerialSql in class AbstractDbObject<P extends AbstractPersistentObject<T,P>>public String createDummyUpdateSql()
createDummyUpdateSql in class AbstractDbObject<P extends AbstractPersistentObject<T,P>>public String createUpdateSerialSql()
createUpdateSerialSql in class AbstractDbObject<P extends AbstractPersistentObject<T,P>>public String createUpdateSerialAndTableSerialSql()
createUpdateSerialAndTableSerialSql in class AbstractDbObject<P extends AbstractPersistentObject<T,P>>public String createSelectExpiredTableSerials1Sql()
createSelectExpiredTableSerials1Sql in class AbstractDbObject<P extends AbstractPersistentObject<T,P>>public String createSelectExpiredTableSerials2Sql()
createSelectExpiredTableSerials2Sql in class AbstractDbObject<P extends AbstractPersistentObject<T,P>>public ResultSetWrapper resultByNormText(String normText, JoinedSelect<T> js)
resultAll(org.tentackle.pdo.JoinedSelect<T>).normText - the normtext to search forjs - the optional join config, null if no joinsresultByNormTextCursor(java.lang.String, org.tentackle.pdo.JoinedSelect<T>)public ResultSetWrapper resultByNormTextCursor(String normText, JoinedSelect<T> js)
ResultSet.TYPE_SCROLL_INSENSITIVE
set.
If the given normtext is null or just "%" the method falls back
to resultAll(org.tentackle.pdo.JoinedSelect<T>).normText - the normtext to search forjs - the optional join config, null if no joinsresultByNormText(java.lang.String, org.tentackle.pdo.JoinedSelect<T>)public List<T> selectByNormText(String normText)
selectByNormText in interface PersistentObject<T extends PersistentDomainObject<T>>normText - the normtextresultByNormText(java.lang.String, org.tentackle.pdo.JoinedSelect<T>)public ScrollableResource<T> selectByNormTextAsCursor(String normText)
selectByNormTextAsCursor in interface PersistentObject<T extends PersistentDomainObject<T>>normText - the normtextresultByNormTextCursor(java.lang.String, org.tentackle.pdo.JoinedSelect<T>)public String createSelectAllSql()
public ResultSetWrapper resultAll(JoinedSelect<T> js)
js - the optional join config, null if no joinsresultAllCursor(org.tentackle.pdo.JoinedSelect<T>)public ResultSetWrapper resultAllCursor(JoinedSelect<T> js)
ResultSet.TYPE_SCROLL_INSENSITIVE set.js - the optional join config, null if no joinsresultAll(org.tentackle.pdo.JoinedSelect<T>)public List<T> selectAll()
selectAll in interface PersistentObject<T extends PersistentDomainObject<T>>resultAll(org.tentackle.pdo.JoinedSelect<T>)public ScrollableResource<T> selectAllAsCursor()
selectAllAsCursor in interface PersistentObject<T extends PersistentDomainObject<T>>resultAllCursor(org.tentackle.pdo.JoinedSelect<T>)public PdoCache<T> getCache()
getCache in interface PersistentObject<T extends PersistentDomainObject<T>>public boolean expireCache(long maxSerial)
cache.expire(maxSerial);
while "cache" has been declared by the wurblet PdoCache.maxSerial - is the new tableSerial this object will getPdoCachepublic T selectCached(long id)
selectCached in interface PersistentObject<T extends PersistentDomainObject<T>>id - the uniue object IDAbstractDbObject.selectObject(long)public T selectCachedOnly(long id)
selectCachedOnly in interface PersistentObject<T extends PersistentDomainObject<T>>id - the uniue object IDAbstractDbObject.selectObject(long)public List<T> selectAllCached()
selectAllCached in interface PersistentObject<T extends PersistentDomainObject<T>>selectAll()public List<T> selectAllForCache()
selectAllForCache in interface PersistentObject<T extends PersistentDomainObject<T>>public T selectForCache(long id)
selectForCache in interface PersistentObject<T extends PersistentDomainObject<T>>public long countModification()
Overridden to expire the cache if object is using the tableserial.
countModification in class AbstractDbObject<P extends AbstractPersistentObject<T,P>>public <T extends PersistentDomainObject<T>> boolean addReferencingClass(Class<T> clazz, String methodName)
T - the PDO typeclazz - the class to addmethodName - a method name, null if defaultremoveReferencingClass(java.lang.Class<T>, java.lang.String)public <T extends PersistentDomainObject<T>> boolean removeReferencingClass(Class<T> clazz, String methodName)
T - the PDO typeclazz - the class to addmethodName - a method name, null if defaultremoveReferencingClass(java.lang.Class<T>, java.lang.String)public <T extends PersistentDomainObject<T>> Class<? extends AbstractPersistentObject<?,?>> getPersistenceClass(Class<T> clazz)
Throws a PersistenceException if the persistence class is not an AbstractPersistentObject.
T - the PDO typeclazz - the pdo classpublic boolean isReferenced()
It is invoked before operations that may have an impact on the referential integrity. The default implementation returns false.
The application can assume a lazy context (invoked from is...Lazy) if invoked outside a transaction. This is just an optimization hint.
Overridden because remote method requires a DomainContext instead of just the db-connection.
isReferenced in interface PersistentObject<T extends PersistentDomainObject<T>>isReferenced in class AbstractDbObject<P extends AbstractPersistentObject<T,P>>public boolean containsPattern(String pattern)
containsPattern in interface PersistentObject<T extends PersistentDomainObject<T>>pattern - the pattern to search forpublic String orderBy()
return CN_ID + "," + CN_PRINTED + " DESC";For a single field with sort ascending returning the fieldname is sufficient. The default is null, i.e. no order-by-clause will be added.
public void initModification(char modType)
Overridden due to security check.
initModification in class AbstractDbObject<P extends AbstractPersistentObject<T,P>>modType - is the modification type: DELETE, INSERT or UPDATEpublic void finishModification(char modType)
Overridden to clear the renewTokenLock flag.
finishModification in class AbstractDbObject<P extends AbstractPersistentObject<T,P>>modType - is the modification type: DELETE, INSERT or UPDATEpublic void finishNotUpdated(char modType)
AbstractPersistentObject.
Ovewritten to get the token lock removed, if any.
finishNotUpdated in class AbstractDbObject<P extends AbstractPersistentObject<T,P>>modType - is the modification type: DELETE, INSERT or UPDATEpublic long getContextUserId()
Note: invokes the errorhandler if some exception or userId is 0.
public void clearTokenLock()
If isRenewTokenLockRequested() is true, the token will be renewed (prolonged
if existing) or created (if not existing).
The operation is only done in memory, not in persistent storage.
public void setRenewTokenLockRequested(boolean renewTokenLock)
By default, the token lock (if set) will be cleared upon insert or update. However, sometimes it is necessary to keep it, renew it respectively.
Setting this flag to true will renew the token upon the next persistence operation. Afterwards the flag will be cleared.
renewTokenLock - true to renew the token (once)public boolean isRenewTokenLockRequested()
protected boolean isUpdateNecessary()
AbstractDbObjectisUpdateNecessary in class AbstractDbObject<P extends AbstractPersistentObject<T,P>>public void updateObject()
AbstractDbObject.saveObject() instead!
Overridden to clear the token lock if remote session.
updateObject in class AbstractDbObject<P extends AbstractPersistentObject<T,P>>public void insertObject()
Note: this method does *NOT* set the ID and should be used
by the application with great care! Use AbstractDbObject.saveObject() instead!
Overridden to clear the token lock if remote session.
insertObject in class AbstractDbObject<P extends AbstractPersistentObject<T,P>>public void newId()
AbstractDbObjectIf the object already has an ID or is deleted (negative ID) the ID will _not_ change.
newId in class AbstractDbObject<P extends AbstractPersistentObject<T,P>>public boolean updateRootContext()
public void configureRemoteObject(DomainContext context, T obj)
context - the local domain contextobj - the objectpublic void configureRemoteObjects(DomainContext context, Collection<T> objects)
context - the local domain contextobjects - the objects to configureprotected void assertRootContext()
protected <X extends PersistentDomainObject<X>> void markDeleted(Collection<X> pdos)
X - the pdo typepdos - the objects to mark deletedprotected void markDeleted(PersistentDomainObject<?> pdo)
pdo - the pdo to mark deletedprotected <X extends PersistentDomainObject<X>> void delete(Collection<X> pdos)
X - the pdo typepdos - the list of object to deleteprotected void delete(PersistentDomainObject<?> pdo)
pdo - the pdo to mark deletedprotected <X extends PersistentDomainObject<X>> void deleteMissingInCollection(Collection<X> oldCollection, Collection<X> newCollection)
X - the PDO typeoldCollection - the list of objects stored in dbnewCollection - the new list of objectspublic void assertRootEntity()
public void delete()
delete in interface PersistentObject<T extends PersistentDomainObject<T>>protected void deleteImpl()
public void save()
save in interface PersistentObject<T extends PersistentDomainObject<T>>protected void saveImpl()
protected <X extends PersistentDomainObject<X>> void save(Collection<X> pdos, boolean modifiedOnly)
X - the pdo typepdos - the list to savemodifiedOnly - true if only modified objects are savedprotected void save(PersistentDomainObject<?> pdo)
pdo - the pdo to savepublic T persist()
persist in interface PersistentObject<T extends PersistentDomainObject<T>>public T persistTokenLocked()
persistTokenLocked in interface PersistentObject<T extends PersistentDomainObject<T>>protected T persistImpl()
public boolean isUpdatingSerialEvenIfNotModified()
The default implementation returns true if this is a root entity.
isUpdatingSerialEvenIfNotModified in class AbstractDbObject<P extends AbstractPersistentObject<T,P>>updateObject()protected <X extends PersistentDomainObject<X>> boolean isModified(Collection<X> pdos)
X - the PDO typepdos - the objectspublic boolean isTokenLockProvided()
isTokenLockProvided in interface PersistentObject<T extends PersistentDomainObject<T>>protected void assertTokenLockProvided()
public long getTokenLockTimeout()
getTokenLockTimeout in interface PersistentObject<T extends PersistentDomainObject<T>>public String createUpdateTokenLockSql()
updateTokenLock(org.tentackle.common.Timestamp, long, org.tentackle.common.Timestamp) statement.public String createUpdateTokenLockWithCountSql()
updateTokenLock(org.tentackle.common.Timestamp, long, org.tentackle.common.Timestamp) statement with mod counting.public String createUpdateTokenLockOnlySql()
updateTokenLockOnly() statement.public String createSelectTokenLockSql()
updateTokenLock(org.tentackle.common.Timestamp, long, org.tentackle.common.Timestamp) statement.public String createTransferTokenLockSql()
transferTokenLock(long) statement without tableserial.public String createTransferTokenLockWithTableSerialSql()
transferTokenLock(long) statement with tableserial.public long getEditedBy()
getEditedBy in interface PersistentObject<T extends PersistentDomainObject<T>>public void setEditedBy(long editedBy)
setEditedBy in interface PersistentObject<T extends PersistentDomainObject<T>>editedBy - the id of the user, 0 to clear.public void requestTokenLock()
requestTokenLock in interface PersistentObject<T extends PersistentDomainObject<T>>public void releaseTokenLock()
releaseTokenLock in interface PersistentObject<T extends PersistentDomainObject<T>>public boolean isTokenLocked()
isTokenLocked in interface PersistentObject<T extends PersistentDomainObject<T>>public boolean isTokenLockedBy(long userId)
isTokenLockedBy in interface PersistentObject<T extends PersistentDomainObject<T>>userId - the user's IDpublic boolean isTokenLockedByMe()
isTokenLockedByMe in interface PersistentObject<T extends PersistentDomainObject<T>>public org.tentackle.common.Timestamp getEditedSince()
getEditedSince in interface PersistentObject<T extends PersistentDomainObject<T>>public void setEditedSince(org.tentackle.common.Timestamp editedSince)
setEditedSince in interface PersistentObject<T extends PersistentDomainObject<T>>editedSince - the time, null to clear.public org.tentackle.common.Timestamp getEditedExpiry()
getEditedExpiry in interface PersistentObject<T extends PersistentDomainObject<T>>public void setEditedExpiry(org.tentackle.common.Timestamp editedExpiry)
setEditedExpiry in interface PersistentObject<T extends PersistentDomainObject<T>>editedExpiry - the expiration time, null to clear.public <U extends PersistentDomainObject<U>> U getTokenLockObject()
AbstractApplication.getUser(org.tentackle.pdo.DomainContext, long).getTokenLockObject in interface PersistentObject<T extends PersistentDomainObject<T>>public <U extends PersistentDomainObject<U>> void setTokenLockObject(U obj)
setTokenLockObject in interface PersistentObject<T extends PersistentDomainObject<T>>obj - the object, null to clear.public boolean isCountingModificationForTokenLock()
public void updateTokenLock(org.tentackle.common.Timestamp tokenExpiry,
long userId,
org.tentackle.common.Timestamp curTime)
2 cases:
If expiry == 0, the "token" is released. True is returned if operation was successful and editedBy will hold 0 while editedSince holds the current (release) time. False is returned if token could not be released and nothing is changed. This usually is the case when another user holds the token (and indicates some logic errors in the application, btw.) EditedBy and editedSince are updated in the object to reflect the current values in the database. Notice: releasing an already released token is not considered to be an error. This will simply update the release timestamp.
If expiry > 0, a new token for the current user is requested. True is returned if the token could be exclusively acquired. EditedBy and editedSince are updated accordingly. If false: the object is in use by another user and editedSince and editedId holds this user and his timestamp. Notice: requesting an already requested token will simply renew the token.
The method does not check getTokenLockTimeout()! This is due to the application. Applications should use updateTokenLock(tokenExpiry). This is an internal implementation only.
tokenExpiry - holds the time the token will expire. Null to release token.userId - is the current user (unused if tokenExpiry is null)curTime - is the current system timepublic void updateTokenLock(org.tentackle.common.Timestamp tokenExpiry)
2 cases:
If expiry == 0, the "token" is released. True is returned if operation was successful and editedBy will hold 0 while editedSince holds the current (release) time. False is returned if token could not be released and nothing is changed. This usually is the case when another user holds the token (and indicates some logic errors in the application, btw.) EditedBy and editedSince are updated in the object to reflect the current values in the database. Notice: releasing an already released token is not considered to be an error. This will simply update the release timestamp.
If expiry > 0, a new token for the current user is requested. True is returned if the token could be exclusively acquired. EditedBy and editedSince are updated accordingly. If false: the object is in use by another user and editedSince and editedId holds this user and his timestamp. Notice: requesting an already requested token will simply renew the token.
The method does not check getTokenLockTimeout()! This is due to the application.
tokenExpiry - holds the time the token will expire. Null to release token.public void updateTokenLockOnly()
public T transferTokenLock(long userId)
transferTokenLock in interface PersistentObject<T extends PersistentDomainObject<T>>public Object getTransientData()
getTransientData in interface PersistentObject<T extends PersistentDomainObject<T>>public void setTransientData(Object data)
setTransientData in interface PersistentObject<T extends PersistentDomainObject<T>>data - the transient datapublic org.tentackle.pdo.rmi.AbstractPersistentObjectRemoteDelegate<T,P> getRemoteDelegate()
Overridden due to covariance.
getRemoteDelegate in class AbstractDbObject<P extends AbstractPersistentObject<T,P>>public Class<? extends ValidationScope>[] getDefaultScopes()
The default scopes are: PersistenceScope, MandatoryScope and ChangeableScope.
getDefaultScopes in interface ScopeConfiguratorpublic List<ValidationResult> validate(String validationPath, ValidationScope scope)
validate in interface Validateablepublic void validate()
validate in interface PersistentObject<T extends PersistentDomainObject<T>>public boolean isValidated()
isValidated in interface PersistentObject<T extends PersistentDomainObject<T>>public void setModified(boolean modified)
AbstractDbObjectFor optimizations it is possible to skip objects that have not been modified. The modified-attribute is cleared whenever the object is saved (inserted or updated -- NOT insertPlain and updatePlain!). The application is responsible to set the modified flag! This is usually done in the setter-methods of the db-attributes. The wurblet 'DbMethods' does this for you with option '--tracked'
If invoked with modified=false (which is the case after been loaded from storage or after successful delete/update/insert) all property change listeners will also be removed.
setModified in interface PersistentObject<T extends PersistentDomainObject<T>>setModified in class AbstractDbObject<P extends AbstractPersistentObject<T,P>>modified - is true if object is flagged modified, false if not.public boolean isReadAllowed()
public boolean isWriteAllowed()
isWriteAllowed in interface PersistentObject<T extends PersistentDomainObject<T>>public boolean isViewAllowed()
isViewAllowed in interface PersistentObject<T extends PersistentDomainObject<T>>public boolean isEditAllowed()
isEditAllowed in interface PersistentObject<T extends PersistentDomainObject<T>>protected void assertWritePermission()
SecurityException - if no write permissionprotected void assertReadPermission()
SecurityException - if no read permissionCopyright © 2016 Krake Softwaretechnik. All rights reserved.