Class AbstractPersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>,​P extends 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.Cloneable
    Base persistent implementation of a PDO.
    Author:
    harald
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String AN_EDITEDBY
      name of the editedBy attribute.
      static java.lang.String AN_EDITEDEXPIRY
      name of the editedExpiry attribute.
      static java.lang.String AN_EDITEDSINCE
      name of the editedSince attribute.
      static java.lang.String AN_NORMTEXT
      name of the normText attribute.
      static java.lang.String AN_ROOTCLASSID
      name of rootclass-ID attribute.
      static java.lang.String AN_ROOTID
      name of root-ID attribute.
      static java.lang.String CN_EDITEDBY
      name of the editedBy column.
      static java.lang.String CN_EDITEDEXPIRY
      name of the editedExpiry column.
      static java.lang.String CN_EDITEDSINCE
      name of the editedSince column.
      static java.lang.String CN_NORMTEXT
      name of the normText column.
      static java.lang.String CN_ROOTCLASSID
      name of rootclass-ID column.
      static java.lang.String CN_ROOTID
      name of root-ID column.
      static java.lang.String TX_DELETE_ALL_IN_CONTEXT
      delete all in context
      static java.lang.String TX_SAVE_COPY_IN_CONTEXT
      saveImpl copy in context
      static java.lang.String TX_TRANSFER_TOKENLOCK
      transfer edited by
      static java.lang.String TX_UPDATE_TOKENLOCK
      update tokenlock
      static java.lang.String TX_UPDATE_TOKENLOCK_ONLY
      update 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
      int addComponents​(org.tentackle.misc.IdentifiableMap<org.tentackle.pdo.PersistentDomainObject<?>> components, boolean onlyLoaded)
      Adds the components of this object to a map.
      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.
      <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.
      protected void addSnapshot​(T snapshot)
      Adds a snapshot to the list of snapshots.
      void applyTokenLockInfo​(org.tentackle.pdo.TokenLockInfo tokenLockInfo)
      Applies the given token lock info.
      protected void assertDomainContextMutable()
      Asserts that the domain context is mutable.
      protected void assertMutable()
      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()
      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.
      boolean clearTokenLock()
      Clears or renews the token lock.
      protected P clone()
      Clones this persistent object.
      The method is final to prevent applications from overriding it and spoiling the contract with createSnapshot().
      void configureRemoteObject​(org.tentackle.pdo.DomainContext context, T obj)
      Configures the remotely retrieved object.
      void configureRemoteObjects​(org.tentackle.pdo.DomainContext context, java.util.Collection<T> objects)
      Configures the remotely retrieved objects.
      boolean containsPattern​(java.lang.String pattern)
      Searches for a "pattern" in this object.
      The default implementation looks for the pattern in the normtext.
      T copy()  
      long countModification()
      protected void createAttributesInSnapshot​(AbstractPersistentObject snapshot)
      Updates the attributes in snapshot object.
      The snapshot object is assumed to be a clone of this object.
      java.lang.StringBuilder createAttributesNormText()
      Creates the normtext of all attributes with the normtext option.
      The method is usually generated by the MethodsImpl wurblet.
      protected void createComponentsInSnapshot​(AbstractPersistentObject snapshot)
      Updates the components in snapshot object.
      The snapshot object is assumed to be a clone of this object.
      java.lang.String createDummyUpdateSql()
      Creates the SQL code for the dummy update statement.
      Useful get an exclusive lock within a transaction.
      protected org.tentackle.misc.PropertySupport createPropertySupport()  
      java.lang.StringBuilder createRelationsNormText()
      Creates the normtext of all relations with the normtext option.
      The method is usually generated by the PdoRelations wurblet.
      java.lang.StringBuilder createSelectAllByIdInnerSql()  
      java.lang.StringBuilder createSelectAllIdSerialInnerSql()  
      java.lang.StringBuilder createSelectAllInnerSql()  
      java.lang.String createSelectAllSql()
      Creates SQL code for select all.
      Appends context condition and order by clause if configured.
      java.lang.String createSelectAllWithExpiredTableSerialsSql()
      Creates SQL code for selectAllWithExpiredTableSerials(long).
      Appends context condition and order by clause if configured.
      By default, the result is sorted by tableserial + id.
      java.lang.String createSelectByNormTextSql​(boolean not)
      Creates the SQL code for select by normtext.
      java.lang.String createSelectExpiredTableSerials1Sql()
      Creates the SQL code for the first statement to select expired table serials.
      java.lang.String createSelectExpiredTableSerials2Sql()
      Creates the SQL code for the second statement to select expired table serials.
      java.lang.StringBuilder createSelectIdInnerSql()  
      java.lang.StringBuilder createSelectIdInnerSql​(boolean withAlias)
      Creates the inner sql text to select the ID field.
      java.lang.StringBuilder createSelectIdInnerSql​(PersistentObjectClassVariables<? super T,​? super P> classVariables, boolean withAlias)
      Creates the inner sql text to select the ID field.
      java.lang.String createSelectMaxIdSql()
      Creates the SQL code for the selectMaxId statement.
      java.lang.String createSelectMaxTableSerialSql()
      Creates the SQL code for the selectMaxTableSerial statement.
      java.lang.String createSelectSerialSql()
      Creates the SQL code for the selectSerial statement.
      java.lang.String createSelectTokenLockSql()
      T createSnapshot()
      Creates a snapshot of this object.
      java.lang.String createTransferTokenLockSql()
      Creates the SQL code for the transferTokenLock(long) statement without tableserial.
      java.lang.String createTransferTokenLockWithTableSerialSql()
      Creates the SQL code for the transferTokenLock(long) statement with tableserial.
      java.lang.String createUpdateSerialAndTableSerialSql()
      Creates the SQL code for the serial + tableSerial update statement.
      java.lang.String createUpdateSerialSql()
      Creates the SQL code for the serial update statement.
      java.lang.String createUpdateTokenLockOnlySql()
      Creates the SQL code for the updateTokenLockOnly() statement.
      java.lang.String createUpdateTokenLockSql()
      java.lang.String createUpdateTokenLockWithCountSql()
      Creates the SQL code for the updateTokenLock(org.tentackle.common.Timestamp, long, org.tentackle.common.Timestamp) statement with mod counting.
      org.tentackle.pdo.DomainContext createValidContext()
      void 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.
      protected void delete​(org.tentackle.pdo.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 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.
      void deleteObject()  
      void deletePlainWithComponents()
      Deletes this object and all its components without any further processing.
      Same as AbstractDbObject.deletePlain() but with components.
      int deletePlainWithComponents​(java.util.Collection<? extends org.tentackle.pdo.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()
      void discardSnapshot​(T snapshot)  
      void discardSnapshots()  
      T executeFirstPdoQuery​(org.tentackle.dbms.PreparedStatementWrapper st)
      Executes a query for a prepared statement and returns the first PDO.
      T executeFirstPdoQuery​(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.
      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.
      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.
      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.
      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 void finishModification​(char modType)
      protected void finishNotUpdated​(char modType)
      org.tentackle.pdo.DomainContext getBaseContext()
      org.tentackle.pdo.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.
      java.lang.String getColumnName​(java.lang.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.
      java.lang.Class<? extends org.tentackle.validate.ValidationScope>[] getDefaultScopes()
      org.tentackle.pdo.DomainContext getDomainContext()
      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.
      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.
      java.lang.Class<T> getEffectiveClass()  
      java.util.List<java.lang.Class<? super T>> getEffectiveSuperClasses()  
      java.lang.String getNormText()
      Gets the normtext.
      T getPdo()  
      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()
      int getRootClassId()  
      long getRootId()  
      org.tentackle.security.SecurityResult getSecurityResult​(org.tentackle.security.Permission permission)  
      java.util.List<T> getSnapshots()  
      java.lang.String getSqlClassIdCondition()
      Gets the additional condition to be used in the WHERE clause for the classid.
      java.lang.String getSqlContextCondition()
      Gets the SQL code for the context condition.
      java.lang.String getTableAlias()
      Gets the table alias.
      java.lang.String getTableName()  
      <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.
      long getTokenLockTimeout()
      Gets the expiration in milliseconds of a token lock.
      If isTokenLockProvided, the default is 1 hour, else 0.
      java.lang.String getTopSuperTableAlias()
      Gets the alias for the topmost super class.
      java.lang.String getTopSuperTableName()
      Gets the tablename for the topmost super class.
      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.
      int getValidClassId()
      Gets the classid.
      protected void initModification​(char modType)
      void insertObject()  
      void insertPlainWithComponents()
      Inserts this object and all its components without any further processing.
      Same as AbstractDbObject.insertPlain() but with components.
      int insertPlainWithComponents​(java.util.Collection<? extends org.tentackle.pdo.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 isCopy()  
      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 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.
      boolean isNormTextProvided()  
      boolean isPermissionAccepted​(org.tentackle.security.Permission permission)  
      boolean isPersistable()  
      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()
      boolean isRenewTokenLockRequested()
      Determines whether to renew the token lock on saveImpl or update.
      boolean isRootClassIdProvided()  
      boolean isRootEntity()
      <C extends org.tentackle.pdo.PersistentDomainObject<C>>
      boolean
      isRootEntityOf​(C component)  
      boolean isRootIdProvided()  
      boolean isSnapshot()  
      boolean isTokenLockableByMe()  
      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()  
      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()  
      org.tentackle.misc.IdentifiableMap<? extends org.tentackle.pdo.PersistentDomainObject<?>> loadComponents​(boolean onlyLoaded)
      void markCacheAccess()
      mark cache access (count and set current system-time)
      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.
      protected void markDeleted​(org.tentackle.pdo.PersistentDomainObject<?> pdo)
      Marks an object to be deleted.
      This method is provided to mark components in PDOs only.
      T me()  
      void newId()  
      java.lang.String orderBy()
      Gets the natural ordering to be added in WHERE-clauses following "ORDER BY ".
      T persist()  
      protected T persistImpl()
      Implementation of persist bypassing the invocation handler.
      T persistTokenLocked()  
      P readFromResultSetWrapper​(org.tentackle.dbms.ResultSetWrapper rs)
      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.
      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 reloadForUpdate()
      Reloads the object with a write lock.
      Restores transient data, if present.
      <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.
      void requestTokenLock()
      Requests an edited by lock.
      org.tentackle.dbms.ResultSetWrapper resultAll​(JoinedSelect<T> js)
      Gets the result set for all objects in the current context for use in lists.
      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 need ResultSet.TYPE_SCROLL_INSENSITIVE set.
      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.
      org.tentackle.dbms.ResultSetWrapper resultByNormText​(java.lang.String text, JoinedSelect<T> js)
      Gets the result set for the normtext query.
      org.tentackle.dbms.ResultSetWrapper resultByNormTextCursor​(java.lang.String text, JoinedSelect<T> js)
      Gets the result set for the normtext query as a cursor.
      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()  
      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.
      static void save​(org.tentackle.pdo.PersistentDomainObject<?> pdo)
      Saves a PDO.
      This method is provided to save components in PDOs only.
      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 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 cursor
      java.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.
      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 selectForUpdate​(long id)
      Loads and write-locks a PDO from the database by its unique ID.
      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.
      void setCopy​(boolean copy)  
      void setDomainContext​(org.tentackle.pdo.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​(java.lang.String normText)
      Sets the normtext.
      void setPdo​(T pdo)
      Sets the 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)
      Sets the class ID of the root entity this component belongs to.
      void setRootId​(long rootId)
      Sets the ID of the root entity this component belongs to.
      <U extends org.tentackle.pdo.PersistentDomainObject<U>>
      void
      setTokenLockObject​(U obj)
      Sets the locking object.
      void setTransientData​(java.lang.Object data)
      Sets the optional transient data object.
      T transferTokenLock​(long userId)  
      void updateNormText()
      Updates the normtext attribute if normtext is provided by this PDO.
      void updateObject()  
      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()  
      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.pdo.DomainContextProvider

        on, op
      • Methods inherited from interface org.tentackle.misc.Identifiable

        toGenericString
      • Methods inherited from interface org.tentackle.misc.Immutable

        getImmutableLoggingLevel, isFinallyImmutable, isImmutable, setFinallyImmutable, setImmutable, setImmutableLoggingLevel
      • Methods inherited from interface org.tentackle.misc.Modifiable

        isModified
      • Methods inherited from interface org.tentackle.dbms.ModificationLoggable

        createModificationLog
      • Methods inherited from interface org.tentackle.pdo.PdoProvider

        on
      • 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
      • Methods inherited from interface org.tentackle.misc.SerialNumbered

        isVirgin
      • Methods inherited from interface org.tentackle.session.SessionDependable

        isSessionImmutable, setSession, setSessionImmutable
      • Methods inherited from interface org.tentackle.session.SessionProvider

        getSession
    • 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 for
        context - 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 for
        session - the session (must be an instance of Session).
      • 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()
        Specified by:
        getDomainDelegate in interface org.tentackle.pdo.PersistenceDelegate<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • getPdo

        public T getPdo()
        Specified by:
        getPdo in interface org.tentackle.pdo.PdoProvider<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • me

        public T me()
        Specified by:
        me in interface org.tentackle.pdo.ProxyDelegate<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • setPdo

        public void setPdo​(T pdo)
        Sets the PDO.
        Parameters:
        pdo - the pdo
      • getEffectiveClass

        public java.lang.Class<T> getEffectiveClass()
        Specified by:
        getEffectiveClass in interface org.tentackle.reflect.EffectiveClassProvider<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • getEffectiveSuperClasses

        public java.util.List<java.lang.Class<? super T>> getEffectiveSuperClasses()
        Specified by:
        getEffectiveSuperClasses in interface org.tentackle.reflect.EffectiveClassProvider<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • getPdoMethodCache

        public org.tentackle.pdo.PdoMethodCache<T> getPdoMethodCache()
        Specified by:
        getPdoMethodCache in interface org.tentackle.pdo.PdoMethodCacheProvider<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • clone

        protected final P clone()
        Clones this persistent object.
        The method is final to prevent applications from overriding it and spoiling the contract with createSnapshot().

        Notice that the proxy pdo is cleared to null in the cloned PO.

        Overrides:
        clone in class java.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.

        Specified by:
        createSnapshot in interface org.tentackle.misc.Snapshotable<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        the snapshot
      • 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.

        Specified by:
        revertToSnapshot in interface org.tentackle.misc.Snapshotable<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Parameters:
        snapshot - the snapshot to revert to
      • copy

        public T copy()
        Specified by:
        copy in interface org.tentackle.misc.Snapshotable<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • 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()
        Specified by:
        isSnapshot in interface org.tentackle.misc.Snapshotable<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • isCopy

        public boolean isCopy()
        Specified by:
        isCopy in interface org.tentackle.misc.Snapshotable<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Overrides:
        isCopy in class org.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,​P>>
      • setCopy

        public void setCopy​(boolean copy)
        Specified by:
        setCopy in interface org.tentackle.misc.Snapshotable<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • getSnapshots

        public java.util.List<T> getSnapshots()
        Specified by:
        getSnapshots in interface org.tentackle.misc.Snapshotable<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • discardSnapshot

        public void discardSnapshot​(T snapshot)
        Specified by:
        discardSnapshot in interface org.tentackle.misc.Snapshotable<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • discardSnapshots

        public void discardSnapshots()
        Specified by:
        discardSnapshots in interface org.tentackle.misc.Snapshotable<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • 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:
        assertMutable in class org.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,​P>>
      • isPersistable

        public boolean isPersistable()
        Specified by:
        isPersistable in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Overrides:
        isPersistable in class org.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,​P>>
      • 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:
        assertPersistable in class org.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,​P>>
      • createPropertySupport

        protected org.tentackle.misc.PropertySupport createPropertySupport()
        Overrides:
        createPropertySupport in class org.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,​P>>
      • isRootEntity

        public boolean isRootEntity()

        The default is false. Override if this is a root-entity.

        Specified by:
        isRootEntity in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • isRootIdProvided

        public boolean isRootIdProvided()
        Specified by:
        isRootIdProvided in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • getRootId

        public long getRootId()
        Specified by:
        getRootId in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • 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()
        Specified by:
        isRootClassIdProvided in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • getRootClassId

        public int getRootClassId()
        Specified by:
        getRootClassId in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • 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)
        Specified by:
        isRootEntityOf in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • isNormTextProvided

        public boolean isNormTextProvided()
        Specified by:
        isNormTextProvided in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • 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.
        Specified by:
        getNormText in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        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:
        isDomainContextImmutable in interface org.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:
        setDomainContextImmutable in interface org.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:
        setDomainContext in interface org.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:
        getDomainContext in interface org.tentackle.pdo.DomainContextProvider
      • determineContextId

        public void determineContextId()

        The default implementation does nothing (object living in a context not depending on another object).

        Specified by:
        determineContextId in interface org.tentackle.pdo.DomainContextDependable
      • getContextId

        public long getContextId()

        The default implementation returns -1.

        Specified by:
        getContextId in interface org.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:
        getBaseContext in interface org.tentackle.pdo.DomainContextDependable
      • createValidContext

        public org.tentackle.pdo.DomainContext createValidContext()

        The default implementation just returns a new DomainContext.

        Specified by:
        createValidContext in interface org.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 of PersistentObjectClassVariables.

        Overrides:
        getClassVariables in class org.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,​P>>
        Returns:
        the class variables
        See Also:
        AbstractDbObject.getClassVariables()
      • getTableName

        public java.lang.String getTableName()
        Specified by:
        getTableName in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Overrides:
        getTableName in class org.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,​P>>
      • 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.
        Specified by:
        isAbstract in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        true if abstract PDO
      • 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.
        Specified by:
        isComposite in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        true if object is composite, false if not.
      • 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.

        Specified by:
        loadComponents in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Parameters:
        onlyLoaded - true if return only already loaded components (lazy composite relations)
        Returns:
        the map of all components, including this object.
      • 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 map
        onlyLoaded - 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 map
        objects - the collection of objects to add along with their components
        onlyLoaded - 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 as AbstractDbObject.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 as AbstractDbObject.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 UnsupportedOperationException if one of those methods are not implemented (which is the default).

        Specified by:
        findDuplicate in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        the duplicate object, null if no duplicate
      • 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.
        Specified by:
        isCacheable in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        true if object is cacheable
      • 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.
        Specified by:
        isExpired in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        true if object is expired (in cache)
      • setExpired

        public void setExpired​(boolean expired)
        Sets this object's expiration flag.
        Specified by:
        setExpired in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Parameters:
        expired - true if object is expired
      • getCacheAccessTime

        public long getCacheAccessTime()
        Gets the last cache access time.
        Specified by:
        getCacheAccessTime in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        the last cache access time
      • getCacheAccessCount

        public long getCacheAccessCount()
        Gets the cache access count.
        Specified by:
        getCacheAccessCount in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        the access count
      • markCacheAccess

        public void markCacheAccess()
        mark cache access (count and set current system-time)
        Specified by:
        markCacheAccess in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • isCached

        public boolean isCached()
        Specified by:
        isCached in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        true if object is cached
      • getSecurityResult

        public org.tentackle.security.SecurityResult getSecurityResult​(org.tentackle.security.Permission permission)
        Specified by:
        getSecurityResult in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • isPermissionAccepted

        public boolean isPermissionAccepted​(org.tentackle.security.Permission permission)
        Specified by:
        isPermissionAccepted in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • 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:
        readFromResultSetWrapper in class org.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 statement
        js - the joined select configuration, null if no joins
        list - 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 wrapper
        js - the joined select configuration, null if no joins
        list - 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 statement
        js - 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 statement
        js - 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 select
        rs - 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 statement
        js - 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 id
        forUpdate - 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 configuration
        st - the statement
        ndx - 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.
        Specified by:
        select in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Parameters:
        id - is the object id
        Returns:
        object if loaded, null if no such object
      • reload

        public T reload()
        Reloads the object.

        Restores transient data, if present.

        Specified by:
        reload in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        the object if reloaded, else null (never this)
      • reloadForUpdate

        public T reloadForUpdate()
        Reloads the object with a write lock.
        Restores transient data, if present.
        Specified by:
        reloadForUpdate in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        the object if reloaded, else null (never this)
      • selectForUpdate

        public T selectForUpdate​(long id)
        Loads and write-locks a PDO from the database by its unique ID.
        Specified by:
        selectForUpdate in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Parameters:
        id - is the object id
        Returns:
        object if loaded, null if no such object
      • derivePdoFromPo

        public T derivePdoFromPo​(T pdo,
                                 P po)
        Derive the concrete PDO from a given PO.
        Parameters:
        pdo - the original persistent domain object
        po - 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:
        createSelectAllInnerSql in class org.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,​P>>
      • createSelectAllIdSerialInnerSql

        public java.lang.StringBuilder createSelectAllIdSerialInnerSql()
        Overrides:
        createSelectAllIdSerialInnerSql in class org.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,​P>>
      • createSelectAllByIdInnerSql

        public java.lang.StringBuilder createSelectAllByIdInnerSql()
        Overrides:
        createSelectAllByIdInnerSql in class org.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 classvariables
        withAlias - 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:
        createSelectIdInnerSql in class org.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:
        createSelectSerialSql in class org.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:
        createSelectMaxIdSql in class org.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:
        createSelectMaxTableSerialSql in class org.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:
        createDummyUpdateSql in class org.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:
        createUpdateSerialSql in class org.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:
        createUpdateSerialAndTableSerialSql in class org.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:
        createSelectExpiredTableSerials1Sql in class org.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:
        createSelectExpiredTableSerials2Sql in class org.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,​P>>
        Returns:
        the sql code
      • selectByNormText

        public java.util.List<T> selectByNormText​(java.lang.String text)
        Selects all objects with a given normtext as a list.
        Specified by:
        selectByNormText in interface org.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:
        selectByNormTextAsCursor in interface org.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 for selectAllWithExpiredTableSerials(long).
        Appends context condition and order by clause if configured.
        By default, the result is sorted by tableserial + id.
        Returns:
        the sql code
      • 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 joins
        oldSerial - 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 need ResultSet.TYPE_SCROLL_INSENSITIVE set.
        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:
        selectAll in interface org.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)
        Specified by:
        selectAllWithExpiredTableSerials in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • selectAllAsCursor

        public org.tentackle.misc.ScrollableResource<T> selectAllAsCursor()
        Selects all records in current context as a cursor
        Specified by:
        selectAllAsCursor in interface org.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.
        Specified by:
        getCache in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        the cache, null if uncached
      • 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.
        Specified by:
        selectCached in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Parameters:
        id - the uniue object ID
        Returns:
        the object, null if no such object
        See Also:
        AbstractDbObject.selectObject(long)
      • 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.
        Specified by:
        selectCachedOnly in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Parameters:
        id - the uniue object ID
        Returns:
        the object, null if no such object
        See Also:
        AbstractDbObject.selectObject(long)
      • 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:
        selectAllCached in interface org.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()
        Specified by:
        selectAllForCache in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • selectForCache

        public T selectForCache​(long id)
        Specified by:
        selectForCache in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • countModification

        public long countModification()

        Overridden to expire the cache if object is using the tableserial.

        Overrides:
        countModification in class org.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 add
        methodName - 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 add
        methodName - 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 DomainContext instead of just the db-connection.

        Specified by:
        isReferenced in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Overrides:
        isReferenced in class org.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,​P>>
      • 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.
        Specified by:
        containsPattern in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Parameters:
        pattern - the pattern to search for
        Returns:
        true if this object "contains" the pattern
      • 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:
        initModification in class org.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,​P>>
      • finishModification

        protected void finishModification​(char modType)

        Overridden to clear the renewTokenLock flag.

        Overrides:
        finishModification in class org.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,​P>>
      • finishNotUpdated

        protected void finishNotUpdated​(char modType)

        Ovewritten to get the token lock removed, if any.

        Overrides:
        finishNotUpdated in class org.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:
        isUpdateNecessary in class org.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,​P>>
      • updateObject

        public void updateObject()
        Overrides:
        updateObject in class org.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,​P>>
      • insertObject

        public void insertObject()
        Overrides:
        insertObject in class org.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,​P>>
      • deleteObject

        public void deleteObject()
        Overrides:
        deleteObject in class org.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,​P>>
      • newId

        public void newId()
        Overrides:
        newId in class org.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 context
        obj - 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 context
        objects - 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 db
        newCollection - the new list of objects
      • assertRootEntity

        public void assertRootEntity()
        Checks if the po is a root entity.
      • delete

        public void delete()
        Specified by:
        delete in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • deleteImpl

        protected void deleteImpl()
        Implementation of delete bypassing the invocation handler.
      • save

        public void save()
        Specified by:
        save in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • 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 save
        modifiedOnly - 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()
        Specified by:
        persist in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • persistTokenLocked

        public T persistTokenLocked()
        Specified by:
        persistTokenLocked in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • 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:
        isUpdatingSerialEvenIfNotModified in class org.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.
        Specified by:
        isTokenLockProvided in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        true if object is using the edited lock columns, false if not.
      • 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.
        Specified by:
        getTokenLockTimeout in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        the timespan in ms, 0 = no token required.
      • createUpdateTokenLockOnlySql

        public java.lang.String createUpdateTokenLockOnlySql()
        Creates the SQL code for the updateTokenLockOnly() statement.
        Returns:
        the sql code
      • createTransferTokenLockSql

        public java.lang.String createTransferTokenLockSql()
        Creates the SQL code for the transferTokenLock(long) statement without tableserial.
        Returns:
        the sql code
      • createTransferTokenLockWithTableSerialSql

        public java.lang.String createTransferTokenLockWithTableSerialSql()
        Creates the SQL code for the transferTokenLock(long) statement with tableserial.
        Returns:
        the sql code
      • getEditedBy

        public long getEditedBy()
        Gets the id of the user currently editing this object.
        Specified by:
        getEditedBy in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        the id or 0 if not being edited currently.
      • 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.
        Specified by:
        requestTokenLock in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • releaseTokenLock

        public void releaseTokenLock()
        Releases an edited by lock.
        Use this method if a PDO needs to be unlocked without being persisted.
        Specified by:
        releaseTokenLock in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • isTokenLocked

        public boolean isTokenLocked()
        Checks whether this object is token locked (editedBy != 0) and the lock is not expired.
        Specified by:
        isTokenLocked in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        true if locked by any user
      • isTokenLockedBy

        public boolean isTokenLockedBy​(long userId)
        Checks whether this object is edited locked by given user.
        Specified by:
        isTokenLockedBy in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Parameters:
        userId - the user's ID
        Returns:
        true locked
      • isTokenLockedByMe

        public boolean isTokenLockedByMe()
        Checks whether this object is edited locked by the current user.
        Specified by:
        isTokenLockedByMe in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        true if locked
      • isTokenLockableByMe

        public boolean isTokenLockableByMe()
        Specified by:
        isTokenLockableByMe in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • getEditedSince

        public org.tentackle.common.Timestamp getEditedSince()
        Gets the time since when this object is being edited.
        Specified by:
        getEditedSince in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        the time, null if not 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.
        Specified by:
        getEditedExpiry in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        the time, null if not 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 invokes AbstractApplication.getUser(org.tentackle.pdo.DomainContext, long).
        Specified by:
        getTokenLockObject in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
        Returns:
        the user object, null if no user or id was 0
      • 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)
        Specified by:
        transferTokenLock in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • 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 methods persist(), reload() and reloadForUpdate() preserve that data via getTransientData() and setTransientData(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:
        getRemoteDelegate in class org.tentackle.dbms.AbstractDbObject<P extends AbstractPersistentObject<T,​P>>
      • getDefaultScopes

        public java.lang.Class<? extends org.tentackle.validate.ValidationScope>[] getDefaultScopes()

        The default scopes are: PersistenceScope, MandatoryScope and ChangeableScope.

        Specified by:
        getDefaultScopes in interface org.tentackle.validate.ScopeConfigurator
      • validate

        public java.util.List<org.tentackle.validate.ValidationResult> validate​(java.lang.String validationPath,
                                                                                org.tentackle.validate.ValidationScope scope)
        Specified by:
        validate in interface org.tentackle.validate.Validateable
      • validate

        public void validate()
        Specified by:
        validate in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • isValidated

        public boolean isValidated()
        Specified by:
        isValidated in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • 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:
        setModified in class org.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()
        Specified by:
        isWriteAllowed in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • isViewAllowed

        public boolean isViewAllowed()
        Specified by:
        isViewAllowed in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • isEditAllowed

        public boolean isEditAllowed()
        Specified by:
        isEditAllowed in interface org.tentackle.pdo.PersistentObject<T extends org.tentackle.pdo.PersistentDomainObject<T>>
      • 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