Class DbTokenLock

java.lang.Object
org.tentackle.dbms.AbstractDbObject<DbTokenLock>
org.tentackle.persist.lock.DbTokenLock
All Implemented Interfaces:
Serializable, Comparable<DbTokenLock>, ModificationLoggable, org.tentackle.misc.Identifiable, org.tentackle.misc.Immutable, org.tentackle.misc.SerialNumbered, TokenLock, org.tentackle.session.SessionDependable, org.tentackle.session.SessionProvider

@ClassId(10) @TableName("tokenlock") public class DbTokenLock extends AbstractDbObject<DbTokenLock> implements TokenLock
Table holding the token locks.

A TokenLock is an add-on to the editedBy/Since/Expiry-token in PDOs.
TokenLocks are maintained by the LockManager.
The ID of the TokenLock is the same as the PDO being locked.
The serial is not related to the PDO, starts at 1 and is incremented whenever lockedBy, lockedSince or lockExpiry changes.
Notice the [NOPKEY] to suppress the generation of the default primary key on id. Instead, the index is unique on (id, pdoclassid). Thus, it is still allowed that objects of different classes share the same id.

Notice, that this table is only used in servers, never in remote clients or simple 2-tier applications.

Author:
harald
See Also:
  • Field Details

  • Constructor Details

    • DbTokenLock

      public DbTokenLock(Db db)
      Creates an empty modification object.
      Parameters:
      db - the session
    • DbTokenLock

      public DbTokenLock()
      Creates an empty modification object.
  • Method Details

    • getClassVariables

      public DbObjectClassVariables<DbTokenLock> getClassVariables()
      Overrides:
      getClassVariables in class AbstractDbObject<DbTokenLock>
    • getFields

      public void getFields(ResultSetWrapper rs)
      Overrides:
      getFields in class AbstractDbObject<DbTokenLock>
    • setFields

      public int setFields(PreparedStatementWrapper st)
      Overrides:
      setFields in class AbstractDbObject<DbTokenLock>
    • createInsertSql

      public String createInsertSql(org.tentackle.sql.Backend backend)
      Overrides:
      createInsertSql in class AbstractDbObject<DbTokenLock>
    • createUpdateSql

      public String createUpdateSql(org.tentackle.sql.Backend backend)
      Overrides:
      createUpdateSql in class AbstractDbObject<DbTokenLock>
    • getPdoClassId

      @Persistent(ordinal=0, comment="class ID of the PDO") public int getPdoClassId()
      Gets the attribute pdoClassId.
      Specified by:
      getPdoClassId in interface TokenLock
      Returns:
      class ID of the PDO
    • setPdoClassId

      public void setPdoClassId(int pdoClassId)
      Sets the attribute pdoClassId.
      Parameters:
      pdoClassId - class ID of the PDO
    • getLockedBy

      @Persistent(ordinal=1, comment="userId of token lock holder") public long getLockedBy()
      Gets the attribute lockedBy.
      Specified by:
      getLockedBy in interface TokenLock
      Returns:
      userId of token lock holder
    • setLockedBy

      public void setLockedBy(long lockedBy)
      Sets the attribute lockedBy.
      Parameters:
      lockedBy - userId of token lock holder
    • getLockedSince

      @Persistent(ordinal=2, comment="time since token lock given to user") public org.tentackle.common.Timestamp getLockedSince()
      Gets the attribute lockedSince.
      Specified by:
      getLockedSince in interface TokenLock
      Returns:
      time since token lock given to user
    • setLockedSince

      public void setLockedSince(org.tentackle.common.Timestamp lockedSince)
      Sets the attribute lockedSince.
      Parameters:
      lockedSince - time since token lock given to user
    • getLockExpiry

      @Persistent(ordinal=3, comment="time when token lock expires") public org.tentackle.common.Timestamp getLockExpiry()
      Gets the attribute lockExpiry.
      Specified by:
      getLockExpiry in interface TokenLock
      Returns:
      time when token lock expires
    • setLockExpiry

      public void setLockExpiry(org.tentackle.common.Timestamp lockExpiry)
      Sets the attribute lockExpiry.
      Parameters:
      lockExpiry - time when token lock expires
    • getPdoId

      public long getPdoId()
      Description copied from interface: TokenLock
      Gets the object id of locked PDO.
      Specified by:
      getPdoId in interface TokenLock
      Returns:
      the object id
    • toDiagnosticString

      public String toDiagnosticString()
      Creates a diagnostic string for logging.
      Returns:
      the diagnostic string