Class AbstractPersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>,P extends AbstractPersistentObject<T,P>>
- java.lang.Object
-
- org.tentackle.dbms.AbstractDbObject<P>
-
- org.tentackle.persist.AbstractPersistentObject<T,P>
-
- Type Parameters:
T- the PDO class (interface)P- the persistence implementation class
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.lang.Comparable<P>,org.tentackle.dbms.ModificationLoggable,org.tentackle.misc.Identifiable,org.tentackle.misc.Immutable,org.tentackle.misc.Modifiable,org.tentackle.misc.SerialNumbered,org.tentackle.misc.Snapshotable<T>,org.tentackle.pdo.DomainContextDependable,org.tentackle.pdo.DomainContextProvider,org.tentackle.pdo.PdoMethodCacheProvider<T>,org.tentackle.pdo.PdoProvider<T>,org.tentackle.pdo.PersistenceDelegate<T>,org.tentackle.pdo.PersistentObject<T>,org.tentackle.pdo.ProxyDelegate<T>,org.tentackle.reflect.EffectiveClassProvider<T>,org.tentackle.reflect.Interceptable,org.tentackle.session.SessionDependable,org.tentackle.session.SessionProvider,org.tentackle.validate.ScopeConfigurator,org.tentackle.validate.Validateable
- Direct Known Subclasses:
NumberPoolPersistenceImpl,NumberRangePersistenceImpl,SecurityPersistenceImpl
public abstract class AbstractPersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>,P extends AbstractPersistentObject<T,P>> extends org.tentackle.dbms.AbstractDbObject<P> implements org.tentackle.pdo.PersistentObject<T>, org.tentackle.reflect.EffectiveClassProvider<T>, org.tentackle.pdo.PdoMethodCacheProvider<T>, java.lang.CloneableBase persistent implementation of a PDO.- Author:
- harald
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringAN_EDITEDBYname of the editedBy attribute.static java.lang.StringAN_EDITEDEXPIRYname of the editedExpiry attribute.static java.lang.StringAN_EDITEDSINCEname of the editedSince attribute.static java.lang.StringAN_NORMTEXTname of the normText attribute.static java.lang.StringAN_ROOTCLASSIDname of rootclass-ID attribute.static java.lang.StringAN_ROOTIDname of root-ID attribute.static java.lang.StringCN_EDITEDBYname of the editedBy column.static java.lang.StringCN_EDITEDEXPIRYname of the editedExpiry column.static java.lang.StringCN_EDITEDSINCEname of the editedSince column.static java.lang.StringCN_NORMTEXTname of the normText column.static java.lang.StringCN_ROOTCLASSIDname of rootclass-ID column.static java.lang.StringCN_ROOTIDname of root-ID column.static java.lang.StringTX_DELETE_ALL_IN_CONTEXTdelete all in contextstatic java.lang.StringTX_SAVE_COPY_IN_CONTEXTsaveImpl copy in contextstatic java.lang.StringTX_TRANSFER_TOKENLOCKtransfer edited bystatic java.lang.StringTX_UPDATE_TOKENLOCKupdate tokenlockstatic java.lang.StringTX_UPDATE_TOKENLOCK_ONLYupdate tokenlock only-
Fields inherited from class org.tentackle.dbms.AbstractDbObject
AN_CLASSID, AN_ID, AN_SERIAL, AN_TABLESERIAL, CN_CLASSID, CN_ID, CN_SERIAL, CN_TABLESERIAL, 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 Summary
Constructors Constructor 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, org.tentackle.pdo.DomainContext context)Creates an application database object.AbstractPersistentObject(T pdo, org.tentackle.session.Session session)Creates an application database object without a domain context for a given connection.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intaddComponents(org.tentackle.misc.IdentifiableMap<org.tentackle.pdo.PersistentDomainObject<?>> components, boolean onlyLoaded)Adds the components of this object to a map.intaddComponents(org.tentackle.misc.IdentifiableMap<org.tentackle.pdo.PersistentDomainObject<?>> components, java.util.Collection<? extends org.tentackle.pdo.PersistentDomainObject<?>> objects, boolean onlyLoaded)Adds the components of a collection to a map.<R extends org.tentackle.pdo.PersistentDomainObject<R>>
booleanaddReferencingClass(java.lang.Class<R> clazz, java.lang.String methodName)Adds a PDO class that is referencing this PDO clazz.protected voidaddSnapshot(T snapshot)Adds a snapshot to the list of snapshots.voidapplyTokenLockInfo(org.tentackle.pdo.TokenLockInfo tokenLockInfo)Applies the given token lock info.protected voidassertDomainContextMutable()Asserts that the domain context is mutable.protected voidassertMutable()protected voidassertNormTextProvided()Asserts that entity provides a normtext.voidassertNotAbstract()Asserts that this is not an abstract entity class.protected voidassertNotCached()Asserts that the PDO is not cached.protected voidassertPersistable()protected voidassertReadPermission()Checks read permission for this object.protected voidassertRootContext()Asserts that the po's context is a root context.voidassertRootContextIsAccepted()Checks the root context agains the security rules.voidassertRootEntity()Checks if the po is a root entity.protected voidassertTokenLockProvided()Asserts that entity provides a normtext.protected voidassertValidSnapshot(T snapshot)Asserts that given snapshot is valid for this object.protected voidassertWritePermission()Checks write permission for this object.booleanclearTokenLock()Clears or renews the token lock.protected Pclone()Clones this persistent object.
The method is final to prevent applications from overriding it and spoiling the contract withcreateSnapshot().voidconfigureRemoteObject(org.tentackle.pdo.DomainContext context, T obj)Configures the remotely retrieved object.voidconfigureRemoteObjects(org.tentackle.pdo.DomainContext context, java.util.Collection<T> objects)Configures the remotely retrieved objects.booleancontainsPattern(java.lang.String pattern)Searches for a "pattern" in this object.
The default implementation looks for the pattern in the normtext.Tcopy()longcountModification()protected voidcreateAttributesInSnapshot(AbstractPersistentObject snapshot)Updates the attributes in snapshot object.
The snapshot object is assumed to be a clone of this object.java.lang.StringBuildercreateAttributesNormText()Creates the normtext of all attributes with the normtext option.
The method is usually generated by the MethodsImpl wurblet.protected voidcreateComponentsInSnapshot(AbstractPersistentObject snapshot)Updates the components in snapshot object.
The snapshot object is assumed to be a clone of this object.java.lang.StringcreateDummyUpdateSql()Creates the SQL code for the dummy update statement.
Useful get an exclusive lock within a transaction.protected org.tentackle.misc.PropertySupportcreatePropertySupport()java.lang.StringBuildercreateRelationsNormText()Creates the normtext of all relations with the normtext option.
The method is usually generated by the PdoRelations wurblet.java.lang.StringBuildercreateSelectAllByIdInnerSql()java.lang.StringBuildercreateSelectAllIdSerialInnerSql()java.lang.StringBuildercreateSelectAllInnerSql()java.lang.StringcreateSelectAllSql()Creates SQL code for select all.
Appends context condition and order by clause if configured.java.lang.StringcreateSelectAllWithExpiredTableSerialsSql()Creates SQL code forselectAllWithExpiredTableSerials(long).
Appends context condition and order by clause if configured.
By default, the result is sorted by tableserial + id.java.lang.StringcreateSelectByNormTextSql(boolean not)Creates the SQL code for select by normtext.java.lang.StringcreateSelectExpiredTableSerials1Sql()Creates the SQL code for the first statement to select expired table serials.java.lang.StringcreateSelectExpiredTableSerials2Sql()Creates the SQL code for the second statement to select expired table serials.java.lang.StringBuildercreateSelectIdInnerSql()java.lang.StringBuildercreateSelectIdInnerSql(boolean withAlias)Creates the inner sql text to select the ID field.java.lang.StringBuildercreateSelectIdInnerSql(PersistentObjectClassVariables<? super T,? super P> classVariables, boolean withAlias)Creates the inner sql text to select the ID field.java.lang.StringcreateSelectMaxIdSql()Creates the SQL code for the selectMaxId statement.java.lang.StringcreateSelectMaxTableSerialSql()Creates the SQL code for the selectMaxTableSerial statement.java.lang.StringcreateSelectSerialSql()Creates the SQL code for the selectSerial statement.java.lang.StringcreateSelectTokenLockSql()Creates the SQL code for the select inupdateTokenLock(org.tentackle.common.Timestamp, long, org.tentackle.common.Timestamp)statement.TcreateSnapshot()Creates a snapshot of this object.java.lang.StringcreateTransferTokenLockSql()Creates the SQL code for thetransferTokenLock(long)statement without tableserial.java.lang.StringcreateTransferTokenLockWithTableSerialSql()Creates the SQL code for thetransferTokenLock(long)statement with tableserial.java.lang.StringcreateUpdateSerialAndTableSerialSql()Creates the SQL code for the serial + tableSerial update statement.java.lang.StringcreateUpdateSerialSql()Creates the SQL code for the serial update statement.java.lang.StringcreateUpdateTokenLockOnlySql()Creates the SQL code for theupdateTokenLockOnly()statement.java.lang.StringcreateUpdateTokenLockSql()Creates the SQL code for theupdateTokenLock(org.tentackle.common.Timestamp, long, org.tentackle.common.Timestamp)statement.java.lang.StringcreateUpdateTokenLockWithCountSql()Creates the SQL code for theupdateTokenLock(org.tentackle.common.Timestamp, long, org.tentackle.common.Timestamp)statement with mod counting.org.tentackle.pdo.DomainContextcreateValidContext()voiddelete()protected <X extends org.tentackle.pdo.PersistentDomainObject<X>>
voiddelete(java.util.Collection<X> pdos)Deletes a List of objects.
This method is provided to mark components in PDOs only.protected voiddelete(org.tentackle.pdo.PersistentDomainObject<?> pdo)Deletes a PDO.
This method is provided to save components in PDOs only.protected voiddeleteImpl()Implementation of delete bypassing the invocation handler.protected <X extends org.tentackle.pdo.PersistentDomainObject<X>>
voiddeleteMissingInCollection(java.util.Collection<X> oldCollection, java.util.Collection<X> newCollection)Deletes all objects in oldList that are not in newList.
This method is provided to save components in PDOs only.voiddeleteObject()voiddeletePlainWithComponents()Deletes this object and all its components without any further processing.
Same asAbstractDbObject.deletePlain()but with components.intdeletePlainWithComponents(java.util.Collection<? extends org.tentackle.pdo.PersistentDomainObject<?>> objects)Deletes plain with components all objects of a collection.TderivePdoFromPo(T pdo, P po)Derive the concrete PDO from a given PO.voiddetermineContextId()voiddiscardSnapshot(T snapshot)voiddiscardSnapshots()TexecuteFirstPdoQuery(org.tentackle.dbms.PreparedStatementWrapper st)Executes a query for a prepared statement and returns the first PDO.TexecuteFirstPdoQuery(org.tentackle.dbms.PreparedStatementWrapper st, JoinedSelect<T> js)Executes a query for a prepared statement and returns the first PDO.java.util.List<T>executeListQuery(org.tentackle.dbms.PreparedStatementWrapper st)Executes the query for a prepared statement and returns the results in a list.java.util.List<T>executeListQuery(org.tentackle.dbms.PreparedStatementWrapper st, JoinedSelect<T> js)Executes the query for a prepared statement and returns the results in a list.voidexecuteQueryToList(org.tentackle.dbms.PreparedStatementWrapper st, JoinedSelect<T> js, java.util.List<T> list)Executes the query for a prepared statement and adds the results to a list.voidexecuteQueryToList(org.tentackle.dbms.ResultSetWrapper rs, JoinedSelect<T> js, java.util.List<T> list)Executes the query for a prepared statement and adds the results to a list.org.tentackle.misc.TrackedList<T>executeTrackedListQuery(org.tentackle.dbms.PreparedStatementWrapper st)Executes the query for a prepared statement and returns the results in a tracked list.org.tentackle.misc.TrackedList<T>executeTrackedListQuery(org.tentackle.dbms.PreparedStatementWrapper st, JoinedSelect<T> js)Executes the query for a prepared statement and returns the results in a tracked list.booleanexpireCache(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...TfindDuplicate()Checks whether this object (if saved) would violate any unique constraints.protected voidfinishModification(char modType)protected voidfinishNotUpdated(char modType)org.tentackle.pdo.DomainContextgetBaseContext()org.tentackle.pdo.PdoCache<T>getCache()Gets the cache.longgetCacheAccessCount()Gets the cache access count.longgetCacheAccessTime()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 ofPersistentObjectClassVariables.java.lang.StringgetColumnName(java.lang.String name)Gets the full column name with optional table alias.longgetContextId()longgetContextUserId()Gets the user id from the current context, i.e.java.lang.Class<? extends org.tentackle.validate.ValidationScope>[]getDefaultScopes()org.tentackle.pdo.DomainContextgetDomainContext()org.tentackle.pdo.DomainDelegate<T>getDomainDelegate()JoinedSelect<T>getEagerJoinedSelect()Adds the eager joins to the created SQL.java.util.List<Join<? super T,?>>getEagerJoins()Returns the eager joins for this PDO.longgetEditedBy()Gets the id of the user currently editing this object.org.tentackle.common.TimestampgetEditedExpiry()Gets the time since when this object is being edited.org.tentackle.common.TimestampgetEditedSince()Gets the time since when this object is being edited.java.lang.Class<T>getEffectiveClass()java.util.List<java.lang.Class<? super T>>getEffectiveSuperClasses()java.lang.StringgetNormText()Gets the normtext.TgetPdo()java.lang.Class<T>getPdoClass()Gets the pdo-class.org.tentackle.pdo.PdoMethodCache<T>getPdoMethodCache()<R extends org.tentackle.pdo.PersistentDomainObject<R>>
java.lang.Class<? extends AbstractPersistentObject<R,?>>getPersistenceClass(java.lang.Class<R> clazz)Gets the persistence class from a pdo class.org.tentackle.persist.rmi.AbstractPersistentObjectRemoteDelegate<T,P>getRemoteDelegate()intgetRootClassId()longgetRootId()org.tentackle.security.SecurityResultgetSecurityResult(org.tentackle.security.Permission permission)java.util.List<T>getSnapshots()java.lang.StringgetSqlClassIdCondition()Gets the additional condition to be used in the WHERE clause for the classid.java.lang.StringgetSqlContextCondition()Gets the SQL code for the context condition.java.lang.StringgetTableAlias()Gets the table alias.java.lang.StringgetTableName()<U extends org.tentackle.pdo.PersistentDomainObject<U>>
UgetTokenLockObject()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.longgetTokenLockTimeout()Gets the expiration in milliseconds of a token lock.
If isTokenLockProvided, the default is 1 hour, else 0.java.lang.StringgetTopSuperTableAlias()Gets the alias for the topmost super class.java.lang.StringgetTopSuperTableName()Gets the tablename for the topmost super class.java.lang.ObjectgetTransientData()Gets the optional transient data object.
When objects need to be reloaded from storage, all non-persistent data attached to the object would be lost.intgetValidClassId()Gets the classid.protected voidinitModification(char modType)voidinsertObject()voidinsertPlainWithComponents()Inserts this object and all its components without any further processing.
Same asAbstractDbObject.insertPlain()but with components.intinsertPlainWithComponents(java.util.Collection<? extends org.tentackle.pdo.PersistentDomainObject<?>> objects)Inserts plain with components all objects of a collection.booleanisAbstract()Returns whether this an abstract PDO.
Abstract PDOs are real objects but cannot be persisted.booleanisCacheable()Determines whether object is cacheable or not.booleanisCached()booleanisClassIdRequiredInWhereClause()Returns whether the classid needs to be inluded in the WHERE-clause.
Applies only to leafs with SINGLE inheritance.booleanisComposite()Tells whether this object is composite (i.e.booleanisCopy()booleanisCountingModificationForTokenLock()booleanisDomainContextImmutable()Returns whether the domain context is immutable.booleanisEditAllowed()booleanisExpired()Checks whether object has been marked expired.booleanisExplicitIdAliasRequiredInJoins()Returns whether an explicit id alias is necessary in joins.
This applies to MULTI-table inherited PDOs only (abstracts and leafs).protected <X extends org.tentackle.pdo.PersistentDomainObject<X>>
booleanisModified(java.util.Collection<X> pdos)Checks whether some of the objects in the list are modified.
This method is provided to save components in PDOs only.booleanisNormTextProvided()booleanisPermissionAccepted(org.tentackle.security.Permission permission)booleanisPersistable()booleanisReadAllowed()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.booleanisReferenced()booleanisRenewTokenLockRequested()Determines whether to renew the token lock on saveImpl or update.booleanisRootClassIdProvided()booleanisRootEntity()<C extends org.tentackle.pdo.PersistentDomainObject<C>>
booleanisRootEntityOf(C component)booleanisRootIdProvided()booleanisSnapshot()booleanisTokenLockableByMe()booleanisTokenLocked()Checks whether this object is token locked (editedBy != 0) and the lock is not expired.booleanisTokenLockedBy(long userId)Checks whether this object is edited locked by given user.booleanisTokenLockedByMe()Checks whether this object is edited locked by the current user.booleanisTokenLockProvided()By default objects don't need to include the editedBy/Since/Expiry columns in the database table.protected booleanisUpdateNecessary()booleanisUpdatingSerialEvenIfNotModified()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.booleanisValidated()booleanisViewAllowed()booleanisWriteAllowed()org.tentackle.misc.IdentifiableMap<? extends org.tentackle.pdo.PersistentDomainObject<?>>loadComponents(boolean onlyLoaded)voidmarkCacheAccess()mark cache access (count and set current system-time)protected <X extends org.tentackle.pdo.PersistentDomainObject<X>>
voidmarkDeleted(java.util.Collection<X> pdos)Marks all objects in a list to be deleted.
This method is provided to mark components in PDOs only.protected voidmarkDeleted(org.tentackle.pdo.PersistentDomainObject<?> pdo)Marks an object to be deleted.
This method is provided to mark components in PDOs only.Tme()voidnewId()java.lang.StringorderBy()Gets the natural ordering to be added in WHERE-clauses following "ORDER BY ".Tpersist()protected TpersistImpl()Implementation of persist bypassing the invocation handler.TpersistTokenLocked()PreadFromResultSetWrapper(org.tentackle.dbms.ResultSetWrapper rs)voidreadJoinedRow(org.tentackle.dbms.ResultSetWrapper rs, JoinedSelect<T> js)Reads the next row from a result set within a joined select.
The results may come in any order.voidreleaseTokenLock()Releases an edited by lock.
Use this method if a PDO needs to be unlocked without being persisted.Treload()Reloads the object.TreloadForUpdate()Reloads the object with a write lock.
Restores transient data, if present.<R extends org.tentackle.pdo.PersistentDomainObject<R>>
booleanremoveReferencingClass(java.lang.Class<R> clazz, java.lang.String methodName)Removes a PDO class that is referencing this PDO clazz.voidrequestTokenLock()Requests an edited by lock.org.tentackle.dbms.ResultSetWrapperresultAll(JoinedSelect<T> js)Gets the result set for all objects in the current context for use in lists.org.tentackle.dbms.ResultSetWrapperresultAllCursor(JoinedSelect<T> js)Gets the result set for all objects in the current context for use in cursors.
Cursors differ from lists because they needResultSet.TYPE_SCROLL_INSENSITIVEset.org.tentackle.dbms.ResultSetWrapperresultAllWithExpiredTableSerials(JoinedSelect<T> js, long oldSerial)Gets the result set for all objects in the current context with a given expired tableserial.org.tentackle.dbms.ResultSetWrapperresultByNormText(java.lang.String text, JoinedSelect<T> js)Gets the result set for the normtext query.org.tentackle.dbms.ResultSetWrapperresultByNormTextCursor(java.lang.String text, JoinedSelect<T> js)Gets the result set for the normtext query as a cursor.protected voidrevertAttributesToSnapshot(AbstractPersistentObject snapshot)Copies all attributes from a snapshot object back to this object.protected voidrevertComponentsToSnapshot(AbstractPersistentObject snapshot)Reverts all components of this object to a given snapshot.voidrevertToSnapshot(T snapshot)Reverts the state of this object to given snapshot.voidsave()static <X extends org.tentackle.pdo.PersistentDomainObject<X>>
voidsave(java.util.Collection<X> pdos, boolean modifiedOnly)Saves a list of PDOs.
This method is provided to save components in PDOs only.static voidsave(org.tentackle.pdo.PersistentDomainObject<?> pdo)Saves a PDO.
This method is provided to save components in PDOs only.protected voidsaveImpl()Implementation of save bypassing the invocation handler.Tselect(long id)Loads a PDO from the database by its unique ID.Tselect(long id, boolean forUpdate)Loads a PDO from the database by its unique ID.java.util.List<T>selectAll()Selects all records in current context as a list.org.tentackle.misc.ScrollableResource<T>selectAllAsCursor()Selects all records in current context as a cursorjava.util.List<T>selectAllCached()Gets all objects in context via cache.java.util.List<T>selectAllForCache()java.util.List<T>selectAllWithExpiredTableSerials(long oldSerial)java.util.List<T>selectByNormText(java.lang.String text)Selects all objects with a given normtext as a list.org.tentackle.misc.ScrollableResource<T>selectByNormTextAsCursor(java.lang.String text)Selects all objects with a given normtext as a cursor.TselectByTemplate(AbstractPersistentObject<T,P> template)Selects an object according to a template object.TselectCached(long id)Gets the object via cache.
If there is no cache (i.e.TselectCachedOnly(long id)Gets the object via cache only.
If there is no cache (i.e.TselectForCache(long id)TselectForUpdate(long id)Loads and write-locks a PDO from the database by its unique ID.protected intsetClassIdsInStatement(JoinedSelect<T> js, org.tentackle.dbms.PreparedStatementWrapper st, int ndx)Sets the class-ID parameters if required for the joins.
Notice that this method only works for joins with no subjoins and is used only for eager joins, i.e.the default selects.
All code for non-eager joins is generated via the DbModelWurblet.voidsetCopy(boolean copy)voidsetDomainContext(org.tentackle.pdo.DomainContext context)voidsetDomainContextImmutable(boolean contextImmutable)Sets the immutable flag of the domain context.voidsetEditedBy(long editedBy)Sets the user editing this object.
Does *NOT* alter isModified() and does not require the object to be mutable.voidsetEditedExpiry(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.voidsetEditedSince(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.voidsetExpired(boolean expired)Sets this object's expiration flag.voidsetModified(boolean modified)Sets the modified flag.voidsetNormText(java.lang.String normText)Sets the normtext.voidsetPdo(T pdo)Sets the PDO.voidsetPersistable(boolean persistable)Sets the local persistable flag.voidsetRenewTokenLockRequested(boolean renewTokenLock)Sets whether to apply or renew the token lock on insert or update.voidsetRootClassId(int rootClassId)Sets the class ID of the root entity this component belongs to.voidsetRootId(long rootId)Sets the ID of the root entity this component belongs to.<U extends org.tentackle.pdo.PersistentDomainObject<U>>
voidsetTokenLockObject(U obj)Sets the locking object.voidsetTransientData(java.lang.Object data)Sets the optional transient data object.TtransferTokenLock(long userId)voidupdateNormText()Updates the normtext attribute if normtext is provided by this PDO.voidupdateObject()booleanupdateRootContext()Updates the root context.
Method is used after deserialization.voidupdateTokenLock(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.voidupdateTokenLock(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.voidupdateTokenLockOnly()Update the editedBy-attributes to persistent storage.
No check is done whether locked or not and there is no serial update and no modlog.voidvalidate()java.util.List<org.tentackle.validate.ValidationResult>validate(java.lang.String validationPath, org.tentackle.validate.ValidationScope scope)-
Methods inherited from class org.tentackle.dbms.AbstractDbObject
acceptPersistenceVisitor, addPropertyListener, addPropertyListener, alignComponents, assertNew, assertNotNew, assertNotOverloaded, assertNotRemote, assertNumberOfRowsAffected, assertRemote, assertThisRowAffected, attributesModified, clearOnRemoteSave, compareTo, createAttributesInSnapshot, createDeleteAllSql, createDeleteSql, createInsertSql, createPreparedStatement, createPreparedStatement, createSelectObjectsWithExpiredTableSerialsSql, createSelectSql, createSqlUpdate, createUpdateAndSetSerialSql, createUpdateSql, deleteImpl, deletePlain, deleteReferencedRelations, deleteReferencingRelations, differsPersisted, dummyUpdate, equals, firePropertyChange, getBackend, getClassBaseName, getClassId, getColumnCount, getExpirationBacklog, getExpiredTableSerials, getFields, getId, getIdSource, getImmutableLoggingLevel, getModificationCount, getModificationLog, getPreparedStatement, getPreparedStatement, getPropertySupport, getSerial, getSession, getSessionHolder, getTableSerial, hashCode, insertImpl, insertPlain, isCountingModification, isDeleted, isEntity, isFinallyImmutable, isForcedModified, isFromThisJVM, isIdValid, isImmutable, isLoggingModification, isModified, isNew, isOverloadable, isRemovable, isSessionImmutable, isStatementAlwaysPrepared, isTableSerialProvided, isTracked, isVirgin, loadLazyReferences, logModification, markDeleted, newInstance, newInstance, newInstance, persistObject, prepareDelete, prepareSave, prepareSetFields, reloadObject, reloadObjectForUpdate, removeAllPropertyListeners, removePropertyListener, removePropertyListener, reserveId, reserveId, resultAllIdSerial, resultAllObjects, resultObjectsWithExpiredTableSerials, revertAttributesToSnapshot, saveObject, saveReferencedRelations, saveReferencingRelations, selectAllIdSerial, selectAllObjects, selectExpiredTableSerials, selectExpiredTableSerials, selectMaxId, selectMaxTableSerial, selectNextObject, selectObject, selectObjectForUpdate, selectObjectsWithExpiredTableSerials, selectSerial, setClassId, setFields, setFinallyImmutable, setId, setImmutable, setImmutableLoggingLevel, setModificationLog, setOverloadable, setSerial, setSession, setSessionHolder, setSessionImmutable, setStatementAlwaysPrepared, setTableSerial, toGenericString, toIdString, toString, unmarkDeleted, updateImpl, updatePlain, updateSerial, updateSerial, updateSerialAndTableSerial
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.tentackle.misc.Immutable
getImmutableLoggingLevel, isFinallyImmutable, isImmutable, setFinallyImmutable, setImmutable, setImmutableLoggingLevel
-
Methods inherited from interface org.tentackle.pdo.PersistentObject
attributesModified, differsPersisted, getClassBaseName, getClassId, getExpiredTableSerials, getId, getModificationCount, getSerial, getTableSerial, isDeleted, isNew, isRemovable, isTableSerialProvided, isTracked, reserveId, reserveId, selectAllIdSerial, selectExpiredTableSerials, selectExpiredTableSerials, selectMaxId, selectMaxTableSerial, selectSerial, toIdString
-
-
-
-
Field Detail
-
CN_EDITEDBY
public static final java.lang.String CN_EDITEDBY
name of the editedBy column.- See Also:
- Constant Field Values
-
AN_EDITEDBY
public static final java.lang.String AN_EDITEDBY
name of the editedBy attribute.- See Also:
- Constant Field Values
-
CN_EDITEDEXPIRY
public static final java.lang.String CN_EDITEDEXPIRY
name of the editedExpiry column.- See Also:
- Constant Field Values
-
AN_EDITEDEXPIRY
public static final java.lang.String AN_EDITEDEXPIRY
name of the editedExpiry attribute.- See Also:
- Constant Field Values
-
CN_EDITEDSINCE
public static final java.lang.String CN_EDITEDSINCE
name of the editedSince column.- See Also:
- Constant Field Values
-
AN_EDITEDSINCE
public static final java.lang.String AN_EDITEDSINCE
name of the editedSince attribute.- See Also:
- Constant Field Values
-
CN_NORMTEXT
public static final java.lang.String CN_NORMTEXT
name of the normText column.- See Also:
- Constant Field Values
-
AN_NORMTEXT
public static final java.lang.String AN_NORMTEXT
name of the normText attribute.- See Also:
- Constant Field Values
-
CN_ROOTID
public static final java.lang.String CN_ROOTID
name of root-ID column.- See Also:
- Constant Field Values
-
AN_ROOTID
public static final java.lang.String AN_ROOTID
name of root-ID attribute.- See Also:
- Constant Field Values
-
CN_ROOTCLASSID
public static final java.lang.String CN_ROOTCLASSID
name of rootclass-ID column.- See Also:
- Constant Field Values
-
AN_ROOTCLASSID
public static final java.lang.String AN_ROOTCLASSID
name of rootclass-ID attribute.- See Also:
- Constant Field Values
-
TX_SAVE_COPY_IN_CONTEXT
public static final java.lang.String TX_SAVE_COPY_IN_CONTEXT
saveImpl copy in context- See Also:
- Constant Field Values
-
TX_DELETE_ALL_IN_CONTEXT
public static final java.lang.String TX_DELETE_ALL_IN_CONTEXT
delete all in context- See Also:
- Constant Field Values
-
TX_TRANSFER_TOKENLOCK
public static final java.lang.String TX_TRANSFER_TOKENLOCK
transfer edited by- See Also:
- Constant Field Values
-
TX_UPDATE_TOKENLOCK
public static final java.lang.String TX_UPDATE_TOKENLOCK
update tokenlock- See Also:
- Constant Field Values
-
TX_UPDATE_TOKENLOCK_ONLY
public static final java.lang.String TX_UPDATE_TOKENLOCK_ONLY
update tokenlock only- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractPersistentObject
public AbstractPersistentObject(T pdo, org.tentackle.pdo.DomainContext context)
Creates an application database object.- Parameters:
pdo- the persistent domain object this is a delegate forcontext- the database context
-
AbstractPersistentObject
public AbstractPersistentObject(T pdo, org.tentackle.session.Session session)
Creates an application database object without a domain context for a given connection.Note: the application must set the context.
- Parameters:
pdo- the persistent domain object this is a delegate forsession- the session (must be an instance ofSession).
-
AbstractPersistentObject
public AbstractPersistentObject(T pdo)
Creates an application database object without a database context.Note: the application must set the context.
- Parameters:
pdo- the persistent domain object this is a delegate for
-
AbstractPersistentObject
public AbstractPersistentObject()
Creates an application database object without a database context.
-
-
Method Detail
-
getDomainDelegate
public org.tentackle.pdo.DomainDelegate<T> getDomainDelegate()
-
getPdo
public T getPdo()
-
me
public T me()
-
setPdo
public void setPdo(T pdo)
Sets the PDO.- Parameters:
pdo- the pdo
-
getEffectiveClass
public java.lang.Class<T> getEffectiveClass()
-
getEffectiveSuperClasses
public java.util.List<java.lang.Class<? super T>> getEffectiveSuperClasses()
-
getPdoMethodCache
public org.tentackle.pdo.PdoMethodCache<T> getPdoMethodCache()
-
clone
protected final P clone()
Clones this persistent object.
The method is final to prevent applications from overriding it and spoiling the contract withcreateSnapshot().Notice that the proxy pdo is cleared to null in the cloned PO.
- Overrides:
clonein classjava.lang.Object- Returns:
- the cloned persistent object
-
createSnapshot
public T createSnapshot()
Creates a snapshot of this object.The method must be implemented. The default implementation just throws PersistenceException.
-
createAttributesInSnapshot
protected void createAttributesInSnapshot(AbstractPersistentObject snapshot)
Updates the attributes in snapshot object.
The snapshot object is assumed to be a clone of this object.- Parameters:
snapshot- the snapshot
-
createComponentsInSnapshot
protected void createComponentsInSnapshot(AbstractPersistentObject snapshot)
Updates the components in snapshot object.
The snapshot object is assumed to be a clone of this object.- Parameters:
snapshot- the snapshot
-
revertToSnapshot
public void revertToSnapshot(T snapshot)
Reverts the state of this object to given snapshot.The method must be implemented. The default implementation just throws PersistenceException.
-
copy
public T copy()
-
revertAttributesToSnapshot
protected void revertAttributesToSnapshot(AbstractPersistentObject snapshot)
Copies all attributes from a snapshot object back to this object.- Parameters:
snapshot- the snapshot object
-
revertComponentsToSnapshot
protected void revertComponentsToSnapshot(AbstractPersistentObject snapshot)
Reverts all components of this object to a given snapshot.- Parameters:
snapshot- the snapshot object
-
isSnapshot
public boolean isSnapshot()
-
isCopy
public boolean isCopy()
-
setCopy
public void setCopy(boolean copy)
-
getSnapshots
public java.util.List<T> getSnapshots()
-
discardSnapshot
public void discardSnapshot(T snapshot)
-
discardSnapshots
public void discardSnapshots()
-
addSnapshot
protected void addSnapshot(T snapshot)
Adds a snapshot to the list of snapshots.- Parameters:
snapshot- the snapshot to add
-
assertValidSnapshot
protected void assertValidSnapshot(T snapshot)
Asserts that given snapshot is valid for this object.- Parameters:
snapshot- the snapshot
-
assertNotCached
protected void assertNotCached()
Asserts that the PDO is not cached.
-
assertMutable
protected void assertMutable()
Overridden due to snapshots are immutable.
- Overrides:
assertMutablein classorg.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,P>>
-
isPersistable
public boolean isPersistable()
-
setPersistable
public void setPersistable(boolean persistable)
Sets the local persistable flag.The implementation maintains an additional flag to disable persistabilty.
- Parameters:
persistable- true if persistable, false if not persistable
-
assertPersistable
protected void assertPersistable()
Overridden to provide detailed exception message.
- Overrides:
assertPersistablein classorg.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,P>>
-
createPropertySupport
protected org.tentackle.misc.PropertySupport createPropertySupport()
- Overrides:
createPropertySupportin classorg.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,P>>
-
isRootEntity
public boolean isRootEntity()
The default is false. Override if this is a root-entity.
-
isRootIdProvided
public boolean isRootIdProvided()
-
getRootId
public long getRootId()
-
setRootId
public void setRootId(long rootId)
Sets the ID of the root entity this component belongs to.- Parameters:
rootId- the root id
-
isRootClassIdProvided
public boolean isRootClassIdProvided()
-
getRootClassId
public int getRootClassId()
-
setRootClassId
public void setRootClassId(int rootClassId)
Sets the class ID of the root entity this component belongs to.- Parameters:
rootClassId- the root class id
-
isRootEntityOf
public <C extends org.tentackle.pdo.PersistentDomainObject<C>> boolean isRootEntityOf(C component)
-
isNormTextProvided
public boolean isNormTextProvided()
-
assertNormTextProvided
protected void assertNormTextProvided()
Asserts that entity provides a normtext.
-
setNormText
public void setNormText(java.lang.String normText)
Sets the normtext.- Parameters:
normText- the normtext
-
getNormText
public java.lang.String getNormText()
Gets the normtext.
-
createAttributesNormText
public java.lang.StringBuilder createAttributesNormText()
Creates the normtext of all attributes with the normtext option.
The method is usually generated by the MethodsImpl wurblet.- Returns:
- the builder holding the unnormalized text, null if no normtext attributes
-
createRelationsNormText
public java.lang.StringBuilder createRelationsNormText()
Creates the normtext of all relations with the normtext option.
The method is usually generated by the PdoRelations wurblet.- Returns:
- the builder holding the unnormalized text, null if no normtext relations
-
updateNormText
public void updateNormText()
Updates the normtext attribute if normtext is provided by this PDO.
-
isDomainContextImmutable
public boolean isDomainContextImmutable()
Returns whether the domain context is immutable.- Specified by:
isDomainContextImmutablein interfaceorg.tentackle.pdo.DomainContextDependable- Returns:
- true if context cannot be changed
-
setDomainContextImmutable
public void setDomainContextImmutable(boolean contextImmutable)
Sets the immutable flag of the domain context.- Specified by:
setDomainContextImmutablein interfaceorg.tentackle.pdo.DomainContextDependable- Parameters:
contextImmutable- true if context cannot be changed
-
assertDomainContextMutable
protected void assertDomainContextMutable()
Asserts that the domain context is mutable.
-
setDomainContext
public void setDomainContext(org.tentackle.pdo.DomainContext context)
Setting the context will also set the session and context id.
- Specified by:
setDomainContextin interfaceorg.tentackle.pdo.DomainContextDependable
-
getDomainContext
public org.tentackle.pdo.DomainContext getDomainContext()
The default implementation just returns the context. Subclasses may override this with a covariant method.
- Specified by:
getDomainContextin interfaceorg.tentackle.pdo.DomainContextProvider
-
determineContextId
public void determineContextId()
The default implementation does nothing (object living in a context not depending on another object).
- Specified by:
determineContextIdin interfaceorg.tentackle.pdo.DomainContextDependable
-
getContextId
public long getContextId()
The default implementation returns -1.
- Specified by:
getContextIdin interfaceorg.tentackle.pdo.DomainContextDependable
-
getSqlContextCondition
public java.lang.String getSqlContextCondition()
Gets the SQL code for the context condition.- Returns:
- null if no condition (default)
-
getSqlClassIdCondition
public java.lang.String getSqlClassIdCondition()
Gets the additional condition to be used in the WHERE clause for the classid.Example: return " AND " + CN_CLASSID + "=?";
- Returns:
- the condition, null if none necessary
-
getBaseContext
public org.tentackle.pdo.DomainContext getBaseContext()
The default implementation returns the PDO's DomainContext.
- Specified by:
getBaseContextin interfaceorg.tentackle.pdo.DomainContextDependable
-
createValidContext
public org.tentackle.pdo.DomainContext createValidContext()
The default implementation just returns a new
DomainContext.- Specified by:
createValidContextin interfaceorg.tentackle.pdo.DomainContextDependable
-
getClassVariables
public 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 ofPersistentObjectClassVariables.- Overrides:
getClassVariablesin classorg.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,P>>- Returns:
- the class variables
- See Also:
AbstractDbObject.getClassVariables()
-
getTableName
public java.lang.String getTableName()
-
getTableAlias
public java.lang.String getTableAlias()
Gets the table alias.- Returns:
- the alias, null if class does not map to a database table
-
getColumnName
public java.lang.String getColumnName(java.lang.String name)
Gets the full column name with optional table alias.- Parameters:
name- the short name- Returns:
- the full name
-
getTopSuperTableAlias
public java.lang.String getTopSuperTableAlias()
Gets the alias for the topmost super class.- Returns:
- the alias
-
getTopSuperTableName
public java.lang.String getTopSuperTableName()
Gets the tablename for the topmost super class.- Returns:
- the alias
-
getPdoClass
public java.lang.Class<T> getPdoClass()
Gets the pdo-class.- Returns:
- the class of the associated PDO
-
isAbstract
public boolean isAbstract()
Returns whether this an abstract PDO.
Abstract PDOs are real objects but cannot be persisted. They may be used to retrieve data for the concrete implementations, however.
-
assertNotAbstract
public void assertNotAbstract()
Asserts that this is not an abstract entity class.
-
getValidClassId
public int getValidClassId()
Gets the classid.- Returns:
- the classid
- Throws:
org.tentackle.session.PersistenceException- if not valid
-
isClassIdRequiredInWhereClause
public boolean isClassIdRequiredInWhereClause()
Returns whether the classid needs to be inluded in the WHERE-clause.
Applies only to leafs with SINGLE inheritance.- Returns:
- true if include classid
-
isExplicitIdAliasRequiredInJoins
public boolean isExplicitIdAliasRequiredInJoins()
Returns whether an explicit id alias is necessary in joins.
This applies to MULTI-table inherited PDOs only (abstracts and leafs).- Returns:
- true if need explicit id alias
-
isComposite
public boolean isComposite()
Tells whether this object is composite (i.e. has composite relations).
The method is overridden by the PdoRelations-wurblet if at least one relation is flagged as "composite". The default implementation returns false.
-
loadComponents
public org.tentackle.misc.IdentifiableMap<? extends org.tentackle.pdo.PersistentDomainObject<?>> loadComponents(boolean onlyLoaded)
By default the method throws a PersistenceException telling that it is not implemented if isComposite() returns true.
-
addComponents
public int addComponents(org.tentackle.misc.IdentifiableMap<org.tentackle.pdo.PersistentDomainObject<?>> components, boolean onlyLoaded)Adds the components of this object to a map.- Parameters:
components- the component maponlyLoaded- true if return only already loaded component (lazy composite relations)- Returns:
- the number of components added
-
addComponents
public int addComponents(org.tentackle.misc.IdentifiableMap<org.tentackle.pdo.PersistentDomainObject<?>> components, java.util.Collection<? extends org.tentackle.pdo.PersistentDomainObject<?>> objects, boolean onlyLoaded)Adds the components of a collection to a map.- Parameters:
components- the components mapobjects- the collection of objects to add along with their componentsonlyLoaded- true if return only already loaded components (lazy composite relations)- Returns:
- the number of components added
-
deletePlainWithComponents
public void deletePlainWithComponents()
Deletes this object and all its components without any further processing.
Same asAbstractDbObject.deletePlain()but with components.
-
deletePlainWithComponents
public int deletePlainWithComponents(java.util.Collection<? extends org.tentackle.pdo.PersistentDomainObject<?>> objects)
Deletes plain with components all objects of a collection.- Parameters:
objects- the collection of PDOs- Returns:
- the number of objects processed, < 0 if failed (number*(-1)-1)
-
insertPlainWithComponents
public void insertPlainWithComponents()
Inserts this object and all its components without any further processing.
Same asAbstractDbObject.insertPlain()but with components.
-
insertPlainWithComponents
public int insertPlainWithComponents(java.util.Collection<? extends org.tentackle.pdo.PersistentDomainObject<?>> objects)
Inserts plain with components all objects of a collection.- Parameters:
objects- the collection of PDOs- Returns:
- the number of objects processed
-
findDuplicate
public T findDuplicate()
Checks whether this object (if saved) would violate any unique constraints.The method is usually used by the presentation layer to check for duplicates. The default implementation invokes findByUniqueDomainKey(getUniqueDomainKey()) and throws
UnsupportedOperationExceptionif one of those methods are not implemented (which is the default).
-
isCacheable
public boolean isCacheable()
Determines whether object is cacheable or not. The default implementation always returns true, but apps can use this as a filter.
-
isExpired
public boolean isExpired()
Checks whether object has been marked expired. Expired objects will be reloaded from the database by the cache when the object is retrieved again.
-
setExpired
public void setExpired(boolean expired)
Sets this object's expiration flag.
-
getCacheAccessTime
public long getCacheAccessTime()
Gets the last cache access time.
-
getCacheAccessCount
public long getCacheAccessCount()
Gets the cache access count.
-
markCacheAccess
public void markCacheAccess()
mark cache access (count and set current system-time)
-
isCached
public boolean isCached()
-
getSecurityResult
public org.tentackle.security.SecurityResult getSecurityResult(org.tentackle.security.Permission permission)
-
isPermissionAccepted
public boolean isPermissionAccepted(org.tentackle.security.Permission permission)
-
selectByTemplate
public T selectByTemplate(AbstractPersistentObject<T,P> template)
Selects an object according to a template object. Useful to find corresponding objects in another context. The default implementation loads the same object by its ID. Should be overwridden to select by some other unique key.- Parameters:
template- the template object- Returns:
- the object if found, else null.
-
getEagerJoinedSelect
public JoinedSelect<T> getEagerJoinedSelect()
Adds the eager joins to the created SQL.- Returns:
- the processed code
-
readFromResultSetWrapper
public P readFromResultSetWrapper(org.tentackle.dbms.ResultSetWrapper rs)
Overridden to implement inheritance and adjust the domain context.
- Overrides:
readFromResultSetWrapperin classorg.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,P>>
-
executeQueryToList
public void executeQueryToList(org.tentackle.dbms.PreparedStatementWrapper st, JoinedSelect<T> js, java.util.List<T> list)Executes the query for a prepared statement and adds the results to a list.- Parameters:
st- the query statementjs- the joined select configuration, null if no joinslist- the list
-
executeQueryToList
public void executeQueryToList(org.tentackle.dbms.ResultSetWrapper rs, JoinedSelect<T> js, java.util.List<T> list)Executes the query for a prepared statement and adds the results to a list.- Parameters:
rs- the result set wrapperjs- the joined select configuration, null if no joinslist- the list
-
executeListQuery
public java.util.List<T> executeListQuery(org.tentackle.dbms.PreparedStatementWrapper st, JoinedSelect<T> js)
Executes the query for a prepared statement and returns the results in a list.- Parameters:
st- the query statementjs- the joined select configuration, null if no joins- Returns:
- the list
-
executeListQuery
public java.util.List<T> executeListQuery(org.tentackle.dbms.PreparedStatementWrapper st)
Executes the query for a prepared statement and returns the results in a list.- Parameters:
st- the query statement- Returns:
- the list
-
executeTrackedListQuery
public org.tentackle.misc.TrackedList<T> executeTrackedListQuery(org.tentackle.dbms.PreparedStatementWrapper st, JoinedSelect<T> js)
Executes the query for a prepared statement and returns the results in a tracked list.- Parameters:
st- the query statementjs- the joined select configuration, null if no joins- Returns:
- the tracked list
-
executeTrackedListQuery
public org.tentackle.misc.TrackedList<T> executeTrackedListQuery(org.tentackle.dbms.PreparedStatementWrapper st)
Executes the query for a prepared statement and returns the results in a tracked list.- Parameters:
st- the query statement- Returns:
- the tracked list
-
getEagerJoins
public java.util.List<Join<? super T,?>> getEagerJoins()
Returns the eager joins for this PDO.- Returns:
- the list of eager joins, null if none
-
readJoinedRow
public void readJoinedRow(org.tentackle.dbms.ResultSetWrapper rs, JoinedSelect<T> js)Reads the next row from a result set within a joined select.
The results may come in any order. Thus, it is possible to sort the results according the to the domain's requirements.- Parameters:
js- the joined selectrs- the result set
-
executeFirstPdoQuery
public T executeFirstPdoQuery(org.tentackle.dbms.PreparedStatementWrapper st, JoinedSelect<T> js)
Executes a query for a prepared statement and returns the first PDO.- Parameters:
st- the query statementjs- the joined select configuration, null if no joins- Returns:
- the PDO
-
executeFirstPdoQuery
public T executeFirstPdoQuery(org.tentackle.dbms.PreparedStatementWrapper st)
Executes a query for a prepared statement and returns the first PDO.- Parameters:
st- the query statement- Returns:
- the PDO
-
select
public T select(long id, boolean forUpdate)
Loads a PDO from the database by its unique ID.- Parameters:
id- is the object idforUpdate- true if select FOR UPDATE- Returns:
- object if loaded, null if no such object
-
setClassIdsInStatement
protected int setClassIdsInStatement(JoinedSelect<T> js, org.tentackle.dbms.PreparedStatementWrapper st, int ndx)
Sets the class-ID parameters if required for the joins.
Notice that this method only works for joins with no subjoins and is used only for eager joins, i.e.the default selects.
All code for non-eager joins is generated via the DbModelWurblet.- Parameters:
js- the join configurationst- the statementndx- the next parameter ndx- Returns:
- the next parameter index
-
select
public T select(long id)
Loads a PDO from the database by its unique ID.
-
reload
public T reload()
Reloads the object.Restores transient data, if present.
-
reloadForUpdate
public T reloadForUpdate()
Reloads the object with a write lock.
Restores transient data, if present.
-
selectForUpdate
public T selectForUpdate(long id)
Loads and write-locks a PDO from the database by its unique ID.
-
derivePdoFromPo
public T derivePdoFromPo(T pdo, P po)
Derive the concrete PDO from a given PO.- Parameters:
pdo- the original persistent domain objectpo- the effective persistent object from readFromResultSetWrapper- Returns:
- the persistent domain object, null if no read permission
-
assertRootContextIsAccepted
public void assertRootContextIsAccepted()
Checks the root context agains the security rules.
-
createSelectAllInnerSql
public java.lang.StringBuilder createSelectAllInnerSql()
- Overrides:
createSelectAllInnerSqlin classorg.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,P>>
-
createSelectAllIdSerialInnerSql
public java.lang.StringBuilder createSelectAllIdSerialInnerSql()
- Overrides:
createSelectAllIdSerialInnerSqlin classorg.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,P>>
-
createSelectAllByIdInnerSql
public java.lang.StringBuilder createSelectAllByIdInnerSql()
- Overrides:
createSelectAllByIdInnerSqlin classorg.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,P>>
-
createSelectIdInnerSql
public java.lang.StringBuilder createSelectIdInnerSql(PersistentObjectClassVariables<? super T,? super P> classVariables, boolean withAlias)
Creates the inner sql text to select the ID field.Returns something like:
"id FROM xytable WHERE 1=1"
- Parameters:
classVariables- the classvariableswithAlias- true if column name with table alias, else without- Returns:
- the sql text
-
createSelectIdInnerSql
public java.lang.StringBuilder createSelectIdInnerSql(boolean withAlias)
Creates the inner sql text to select the ID field.Returns something like:
"id FROM xytable WHERE 1=1"
- Parameters:
withAlias- true if column name with table alias, else without- Returns:
- the sql text
-
createSelectIdInnerSql
public java.lang.StringBuilder createSelectIdInnerSql()
- Overrides:
createSelectIdInnerSqlin classorg.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,P>>
-
createSelectByNormTextSql
public java.lang.String createSelectByNormTextSql(boolean not)
Creates the SQL code for select by normtext.- Parameters:
not- true if find all not matching the normtext- Returns:
- the sql code
-
createSelectSerialSql
public java.lang.String createSelectSerialSql()
Creates the SQL code for the selectSerial statement.- Overrides:
createSelectSerialSqlin classorg.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,P>>- Returns:
- the sql code
-
createSelectMaxIdSql
public java.lang.String createSelectMaxIdSql()
Creates the SQL code for the selectMaxId statement.- Overrides:
createSelectMaxIdSqlin classorg.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,P>>- Returns:
- the sql code
-
createSelectMaxTableSerialSql
public java.lang.String createSelectMaxTableSerialSql()
Creates the SQL code for the selectMaxTableSerial statement.- Overrides:
createSelectMaxTableSerialSqlin classorg.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,P>>- Returns:
- the sql code
-
createDummyUpdateSql
public java.lang.String createDummyUpdateSql()
Creates the SQL code for the dummy update statement.
Useful get an exclusive lock within a transaction.- Overrides:
createDummyUpdateSqlin classorg.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,P>>- Returns:
- the sql code
-
createUpdateSerialSql
public java.lang.String createUpdateSerialSql()
Creates the SQL code for the serial update statement.- Overrides:
createUpdateSerialSqlin classorg.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,P>>- Returns:
- the sql code
-
createUpdateSerialAndTableSerialSql
public java.lang.String createUpdateSerialAndTableSerialSql()
Creates the SQL code for the serial + tableSerial update statement.- Overrides:
createUpdateSerialAndTableSerialSqlin classorg.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,P>>- Returns:
- the sql code
-
createSelectExpiredTableSerials1Sql
public java.lang.String createSelectExpiredTableSerials1Sql()
Creates the SQL code for the first statement to select expired table serials.- Overrides:
createSelectExpiredTableSerials1Sqlin classorg.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,P>>- Returns:
- the sql code
-
createSelectExpiredTableSerials2Sql
public java.lang.String createSelectExpiredTableSerials2Sql()
Creates the SQL code for the second statement to select expired table serials.- Overrides:
createSelectExpiredTableSerials2Sqlin classorg.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,P>>- Returns:
- the sql code
-
resultByNormText
public org.tentackle.dbms.ResultSetWrapper resultByNormText(java.lang.String text, JoinedSelect<T> js)Gets the result set for the normtext query.- Parameters:
text- the text to search forjs- the optional join config, null if no joins- Returns:
- the result set
- See Also:
NormText,resultByNormTextCursor(java.lang.String, org.tentackle.persist.JoinedSelect<T>)
-
resultByNormTextCursor
public org.tentackle.dbms.ResultSetWrapper resultByNormTextCursor(java.lang.String text, JoinedSelect<T> js)Gets the result set for the normtext query as a cursor.- Parameters:
text- the text to search forjs- the optional join config, null if no joins- Returns:
- the result set
- See Also:
NormText,resultByNormText(java.lang.String, org.tentackle.persist.JoinedSelect<T>)
-
selectByNormText
public java.util.List<T> selectByNormText(java.lang.String text)
Selects all objects with a given normtext as a list.- Specified by:
selectByNormTextin interfaceorg.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>- Parameters:
text- the text to search for- Returns:
- the list of objects, never null
- See Also:
resultByNormText(java.lang.String, org.tentackle.persist.JoinedSelect<T>)
-
selectByNormTextAsCursor
public org.tentackle.misc.ScrollableResource<T> selectByNormTextAsCursor(java.lang.String text)
Selects all objects with a given normtext as a cursor.- Specified by:
selectByNormTextAsCursorin interfaceorg.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>- Parameters:
text- the text to search for- Returns:
- the cursor
- See Also:
resultByNormTextCursor(java.lang.String, org.tentackle.persist.JoinedSelect<T>)
-
createSelectAllSql
public java.lang.String createSelectAllSql()
Creates SQL code for select all.
Appends context condition and order by clause if configured.- Returns:
- the sql code
-
createSelectAllWithExpiredTableSerialsSql
public java.lang.String createSelectAllWithExpiredTableSerialsSql()
Creates SQL code forselectAllWithExpiredTableSerials(long).
Appends context condition and order by clause if configured.
By default, the result is sorted by tableserial + id.- Returns:
- the sql code
-
resultAll
public org.tentackle.dbms.ResultSetWrapper resultAll(JoinedSelect<T> js)
Gets the result set for all objects in the current context for use in lists.- Parameters:
js- the optional join config, null if no joins- Returns:
- the result set
- See Also:
resultAllCursor(org.tentackle.persist.JoinedSelect<T>)
-
resultAllWithExpiredTableSerials
public org.tentackle.dbms.ResultSetWrapper resultAllWithExpiredTableSerials(JoinedSelect<T> js, long oldSerial)
Gets the result set for all objects in the current context with a given expired tableserial.- Parameters:
js- the optional join config, null if no joinsoldSerial- the last known tableserial- Returns:
- the result set
-
resultAllCursor
public org.tentackle.dbms.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 needResultSet.TYPE_SCROLL_INSENSITIVEset.- Parameters:
js- the optional join config, null if no joins- Returns:
- the result set
- See Also:
resultAll(org.tentackle.persist.JoinedSelect<T>)
-
selectAll
public java.util.List<T> selectAll()
Selects all records in current context as a list.- Specified by:
selectAllin interfaceorg.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>- Returns:
- the list of objects, never null
- See Also:
resultAll(org.tentackle.persist.JoinedSelect<T>)
-
selectAllWithExpiredTableSerials
public java.util.List<T> selectAllWithExpiredTableSerials(long oldSerial)
-
selectAllAsCursor
public org.tentackle.misc.ScrollableResource<T> selectAllAsCursor()
Selects all records in current context as a cursor- Specified by:
selectAllAsCursorin interfaceorg.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>- Returns:
- the cursor
- See Also:
resultAllCursor(org.tentackle.persist.JoinedSelect<T>)
-
getCache
public org.tentackle.pdo.PdoCache<T> getCache()
Gets the cache. The default implementation returns null. Must be overridden to enable optimization features with RMI servers.
-
expireCache
public 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... Furthermore, if there is a cache, isCountingModification() MUST return true, in order for countModification() to invalidate the cache for the local JVM. Classes with a cache must override this method! The implementation with the PdoCache should look like this:cache.expire(maxSerial);while "cache" has been declared by the wurblet PdoCache.- Parameters:
maxSerial- is the new tableSerial this object will get- Returns:
- true if cache invalidated, false if there is no cache
- See Also:
PdoCache
-
selectCached
public T selectCached(long id)
Gets the object via cache.
If there is no cache (i.e. the method is not overridden), the default implementation just loads from the db.
-
selectCachedOnly
public T selectCachedOnly(long id)
Gets the object via cache only.
If there is no cache (i.e. the method is not overridden), the default implementation just loads from the db.
-
selectAllCached
public java.util.List<T> selectAllCached()
Gets all objects in context via cache. If there is no cache (i.e. the method is not overridden), the default implementation gets it from the db.- Specified by:
selectAllCachedin interfaceorg.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>- Returns:
- the list, never null
- See Also:
selectAll()
-
selectAllForCache
public java.util.List<T> selectAllForCache()
-
selectForCache
public T selectForCache(long id)
-
countModification
public long countModification()
Overridden to expire the cache if object is using the tableserial.
- Overrides:
countModificationin classorg.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,P>>
-
addReferencingClass
public <R extends org.tentackle.pdo.PersistentDomainObject<R>> boolean addReferencingClass(java.lang.Class<R> clazz, java.lang.String methodName)Adds a PDO class that is referencing this PDO clazz.- Type Parameters:
R- the PDO type- Parameters:
clazz- the class to addmethodName- a method name, null if default- Returns:
- true if added, false if already in map
- See Also:
removeReferencingClass(java.lang.Class<R>, java.lang.String)
-
removeReferencingClass
public <R extends org.tentackle.pdo.PersistentDomainObject<R>> boolean removeReferencingClass(java.lang.Class<R> clazz, java.lang.String methodName)Removes a PDO class that is referencing this PDO clazz.- Type Parameters:
R- the PDO type- Parameters:
clazz- the class to addmethodName- a method name, null if default- Returns:
- true if removed, false if not in map
- See Also:
removeReferencingClass(java.lang.Class<R>, java.lang.String)
-
getPersistenceClass
public <R extends org.tentackle.pdo.PersistentDomainObject<R>> java.lang.Class<? extends AbstractPersistentObject<R,?>> getPersistenceClass(java.lang.Class<R> clazz)
Gets the persistence class from a pdo class.Throws a PersistenceException if the persistence class is not an
AbstractPersistentObject.- Type Parameters:
R- the PDO type- Parameters:
clazz- the pdo class- Returns:
- the persistence class
-
isReferenced
public boolean isReferenced()
Overridden because remote method requires a
DomainContextinstead of just the db-connection.
-
containsPattern
public boolean containsPattern(java.lang.String pattern)
Searches for a "pattern" in this object.
The default implementation looks for the pattern in the normtext.
-
orderBy
public java.lang.String orderBy()
Gets the natural ordering to be added in WHERE-clauses following "ORDER BY ". The wurblets will use it if --sort option set. Example: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.- Returns:
- the order by appendix string, null if no order by
-
initModification
protected void initModification(char modType)
Overridden due to security check.
- Overrides:
initModificationin classorg.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,P>>
-
finishModification
protected void finishModification(char modType)
Overridden to clear the renewTokenLock flag.
- Overrides:
finishModificationin classorg.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,P>>
-
finishNotUpdated
protected void finishNotUpdated(char modType)
Ovewritten to get the token lock removed, if any.
- Overrides:
finishNotUpdatedin classorg.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,P>>
-
getContextUserId
public long getContextUserId()
Gets the user id from the current context, i.e. userinfo.Note: invokes the errorhandler if some exception or userId is 0.
- Returns:
- the userId
-
clearTokenLock
public boolean clearTokenLock()
Clears or renews the token lock.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.- Returns:
- true if token lock set or updated, false if token lock cleared or PDO does not provide a token lock
-
setRenewTokenLockRequested
public void setRenewTokenLockRequested(boolean renewTokenLock)
Sets whether to apply or renew the token lock on insert or update.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.
- Parameters:
renewTokenLock- true to renew the token (once)
-
isRenewTokenLockRequested
public boolean isRenewTokenLockRequested()
Determines whether to renew the token lock on saveImpl or update.- Returns:
- true to renew the token (once), false to clear token (default)
-
isUpdateNecessary
protected boolean isUpdateNecessary()
- Overrides:
isUpdateNecessaryin classorg.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,P>>
-
updateObject
public void updateObject()
- Overrides:
updateObjectin classorg.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,P>>
-
insertObject
public void insertObject()
- Overrides:
insertObjectin classorg.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,P>>
-
deleteObject
public void deleteObject()
- Overrides:
deleteObjectin classorg.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,P>>
-
newId
public void newId()
- Overrides:
newIdin classorg.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,P>>
-
updateRootContext
public boolean updateRootContext()
Updates the root context.
Method is used after deserialization.- Returns:
- true if root context set, false if this is not a root-entity
-
configureRemoteObject
public void configureRemoteObject(org.tentackle.pdo.DomainContext context, T obj)Configures the remotely retrieved object.- Parameters:
context- the local domain contextobj- the object
-
configureRemoteObjects
public void configureRemoteObjects(org.tentackle.pdo.DomainContext context, java.util.Collection<T> objects)Configures the remotely retrieved objects.- Parameters:
context- the local domain contextobjects- the objects to configure
-
assertRootContext
protected void assertRootContext()
Asserts that the po's context is a root context.
-
markDeleted
protected <X extends org.tentackle.pdo.PersistentDomainObject<X>> void markDeleted(java.util.Collection<X> pdos)
Marks all objects in a list to be deleted.
This method is provided to mark components in PDOs only. This method must not be used from within the application!- Type Parameters:
X- the pdo type- Parameters:
pdos- the objects to mark deleted
-
markDeleted
protected void markDeleted(org.tentackle.pdo.PersistentDomainObject<?> pdo)
Marks an object to be deleted.
This method is provided to mark components in PDOs only. This method must not be used from within the application!- Parameters:
pdo- the pdo to mark deleted
-
delete
protected <X extends org.tentackle.pdo.PersistentDomainObject<X>> void delete(java.util.Collection<X> pdos)
Deletes a List of objects.
This method is provided to mark components in PDOs only. This method must not be used from within the application!- Type Parameters:
X- the pdo type- Parameters:
pdos- the list of object to delete
-
delete
protected void delete(org.tentackle.pdo.PersistentDomainObject<?> pdo)
Deletes a PDO.
This method is provided to save components in PDOs only. This method must not be used from within the application!- Parameters:
pdo- the pdo to mark deleted
-
deleteMissingInCollection
protected <X extends org.tentackle.pdo.PersistentDomainObject<X>> void deleteMissingInCollection(java.util.Collection<X> oldCollection, java.util.Collection<X> newCollection)Deletes all objects in oldList that are not in newList.
This method is provided to save components in PDOs only. This method must not be used from within the application!- Type Parameters:
X- the PDO type- Parameters:
oldCollection- the list of objects stored in dbnewCollection- the new list of objects
-
assertRootEntity
public void assertRootEntity()
Checks if the po is a root entity.
-
delete
public void delete()
-
deleteImpl
protected void deleteImpl()
Implementation of delete bypassing the invocation handler.
-
save
public void save()
-
saveImpl
protected void saveImpl()
Implementation of save bypassing the invocation handler.
-
save
public static <X extends org.tentackle.pdo.PersistentDomainObject<X>> void save(java.util.Collection<X> pdos, boolean modifiedOnly)Saves a list of PDOs.
This method is provided to save components in PDOs only. Assumes that a transaction is already running. This method must not be used from within the application!- Type Parameters:
X- the pdo type- Parameters:
pdos- the list to savemodifiedOnly- true if only modified objects are saved
-
save
public static void save(org.tentackle.pdo.PersistentDomainObject<?> pdo)
Saves a PDO.
This method is provided to save components in PDOs only. This method must not be used from within the application!- Parameters:
pdo- the pdo to save
-
persist
public T persist()
-
persistTokenLocked
public T persistTokenLocked()
-
persistImpl
protected T persistImpl()
Implementation of persist bypassing the invocation handler.- Returns:
- the persisted PDO
-
isUpdatingSerialEvenIfNotModified
public 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. The default is to leave unmodified objects untouched, except root entities. However, in some applications it is necessary to update the master object if some of its childs are updated (usually to trigger something, e.g. a cache-update).The default implementation returns true if this is a root entity.
- Overrides:
isUpdatingSerialEvenIfNotModifiedin classorg.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,P>>- Returns:
- true if update serial even if object is unchanged
- See Also:
updateObject()
-
isModified
protected <X extends org.tentackle.pdo.PersistentDomainObject<X>> boolean isModified(java.util.Collection<X> pdos)
Checks whether some of the objects in the list are modified.
This method is provided to save components in PDOs only. Assumes that a transaction is already running. This method must not be used from within the application!- Type Parameters:
X- the PDO type- Parameters:
pdos- the objects- Returns:
- true if modified
-
isTokenLockProvided
public boolean isTokenLockProvided()
By default objects don't need to include the editedBy/Since/Expiry columns in the database table. Override this method if object contains such columns, i.e. global model option [TOKENLOCK] set.
-
assertTokenLockProvided
protected void assertTokenLockProvided()
Asserts that entity provides a normtext.
-
getTokenLockTimeout
public long getTokenLockTimeout()
Gets the expiration in milliseconds of a token lock.
If isTokenLockProvided, the default is 1 hour, else 0.
-
createUpdateTokenLockSql
public java.lang.String createUpdateTokenLockSql()
Creates the SQL code for theupdateTokenLock(org.tentackle.common.Timestamp, long, org.tentackle.common.Timestamp)statement.- Returns:
- the sql code
-
createUpdateTokenLockWithCountSql
public java.lang.String createUpdateTokenLockWithCountSql()
Creates the SQL code for theupdateTokenLock(org.tentackle.common.Timestamp, long, org.tentackle.common.Timestamp)statement with mod counting.- Returns:
- the sql code
-
createUpdateTokenLockOnlySql
public java.lang.String createUpdateTokenLockOnlySql()
Creates the SQL code for theupdateTokenLockOnly()statement.- Returns:
- the sql code
-
createSelectTokenLockSql
public java.lang.String createSelectTokenLockSql()
Creates the SQL code for the select inupdateTokenLock(org.tentackle.common.Timestamp, long, org.tentackle.common.Timestamp)statement.- Returns:
- the sql code
-
createTransferTokenLockSql
public java.lang.String createTransferTokenLockSql()
Creates the SQL code for thetransferTokenLock(long)statement without tableserial.- Returns:
- the sql code
-
createTransferTokenLockWithTableSerialSql
public java.lang.String createTransferTokenLockWithTableSerialSql()
Creates the SQL code for thetransferTokenLock(long)statement with tableserial.- Returns:
- the sql code
-
getEditedBy
public long getEditedBy()
Gets the id of the user currently editing this object.
-
setEditedBy
public void setEditedBy(long editedBy)
Sets the user editing this object.
Does *NOT* alter isModified() and does not require the object to be mutable.- Parameters:
editedBy- the id of the user, 0 to clear.
-
requestTokenLock
public void requestTokenLock()
Requests an edited by lock.
-
releaseTokenLock
public void releaseTokenLock()
Releases an edited by lock.
Use this method if a PDO needs to be unlocked without being persisted.
-
isTokenLocked
public boolean isTokenLocked()
Checks whether this object is token locked (editedBy != 0) and the lock is not expired.
-
isTokenLockedBy
public boolean isTokenLockedBy(long userId)
Checks whether this object is edited locked by given user.
-
isTokenLockedByMe
public boolean isTokenLockedByMe()
Checks whether this object is edited locked by the current user.
-
isTokenLockableByMe
public boolean isTokenLockableByMe()
-
getEditedSince
public org.tentackle.common.Timestamp getEditedSince()
Gets the time since when this object is being edited.
-
setEditedSince
public 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.- Parameters:
editedSince- the time, null to clear.
-
getEditedExpiry
public org.tentackle.common.Timestamp getEditedExpiry()
Gets the time since when this object is being edited.
-
setEditedExpiry
public 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.- Parameters:
editedExpiry- the expiration time, null to clear.
-
getTokenLockObject
public <U extends org.tentackle.pdo.PersistentDomainObject<U>> 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. The default implementation invokesAbstractApplication.getUser(org.tentackle.pdo.DomainContext, long).
-
setTokenLockObject
public <U extends org.tentackle.pdo.PersistentDomainObject<U>> void setTokenLockObject(U obj)
Sets the locking object.CAUTION: the method is provided for rare corner cases like administration tools. Don't use it for regular locking/unlocking!
- Type Parameters:
U- the locking object type- Parameters:
obj- the locking object, null to clear.
-
isCountingModificationForTokenLock
public boolean isCountingModificationForTokenLock()
-
applyTokenLockInfo
public void applyTokenLockInfo(org.tentackle.pdo.TokenLockInfo tokenLockInfo)
Applies the given token lock info.- Parameters:
tokenLockInfo- the editedBy info
-
updateTokenLock
public 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.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.
- Parameters:
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 time
-
updateTokenLock
public 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. See PdoEditDialog.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.
- Parameters:
tokenExpiry- holds the time the token will expire. Null to release token.
-
updateTokenLockOnly
public 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. Used by daemons to cleanup.
-
transferTokenLock
public T transferTokenLock(long userId)
-
getTransientData
public java.lang.Object getTransientData()
Gets the optional transient data object.
When objects need to be reloaded from storage, all non-persistent data attached to the object would be lost. The methodspersist(),reload()andreloadForUpdate()preserve that data viagetTransientData()andsetTransientData(Object). Applications must override those methods.
The default implementation does nothing.- Returns:
- the transient data, null if none
- See Also:
setTransientData(Object)
-
setTransientData
public void setTransientData(java.lang.Object data)
Sets the optional transient data object.- Parameters:
data- the transient data- See Also:
getTransientData()
-
getRemoteDelegate
public org.tentackle.persist.rmi.AbstractPersistentObjectRemoteDelegate<T,P> getRemoteDelegate()
Overridden due to covariance.
- Overrides:
getRemoteDelegatein classorg.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,P>>
-
getDefaultScopes
public java.lang.Class<? extends org.tentackle.validate.ValidationScope>[] getDefaultScopes()
The default scopes are:
PersistenceScope,MandatoryScopeandChangeableScope.- Specified by:
getDefaultScopesin interfaceorg.tentackle.validate.ScopeConfigurator
-
validate
public java.util.List<org.tentackle.validate.ValidationResult> validate(java.lang.String validationPath, org.tentackle.validate.ValidationScope scope)- Specified by:
validatein interfaceorg.tentackle.validate.Validateable
-
validate
public void validate()
-
isValidated
public boolean isValidated()
-
setModified
public void setModified(boolean modified)
Sets the modified flag.For optimizations it is possible to skip objects that have not been modified. The modified-attribute is cleared whenever the object is persisted.
- Overrides:
setModifiedin classorg.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,P>>- Parameters:
modified- is true if object is flagged modified, false if not.
-
isReadAllowed
public 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.- Returns:
- true if allowed
-
isWriteAllowed
public boolean isWriteAllowed()
-
isViewAllowed
public boolean isViewAllowed()
-
isEditAllowed
public boolean isEditAllowed()
-
assertWritePermission
protected void assertWritePermission()
Checks write permission for this object.- Throws:
org.tentackle.security.SecurityException- if no write permission
-
assertReadPermission
protected void assertReadPermission()
Checks read permission for this object.- Throws:
org.tentackle.security.SecurityException- if no read permission
-
-