Class PersistentObjectClassVariables<T extends org.tentackle.pdo.PersistentDomainObject<T>,P extends AbstractPersistentObject<T,P>>
- java.lang.Object
-
- org.tentackle.dbms.DbObjectClassVariables<P>
-
- org.tentackle.persist.PersistentObjectClassVariables<T,P>
-
- Type Parameters:
T- the PDO class typeP- the persistence class type
public class PersistentObjectClassVariables<T extends org.tentackle.pdo.PersistentDomainObject<T>,P extends AbstractPersistentObject<T,P>> extends org.tentackle.dbms.DbObjectClassVariables<P>ExtendsDbObjectClassVariablesforAbstractPersistentObjects.- Author:
- harald
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCLASSVARIABLES_NAMEthe declared name of the static class variables.java.util.List<Join<T,?>>eagerJoinsThe optional eager join.org.tentackle.pdo.PdoMethodCache<T>methodCacheThe PDO method invocation cache.java.lang.Class<T>pdoClassThe associated PDO class (i.e.java.lang.StringpdoClassBaseNamethe pdo base-classname.static java.lang.StringPROPERTY_CHECKSECURITYproperty key for the check security.org.tentackle.dbms.StatementIdselectAllCursorStatementIdprepared statement ID forAbstractPersistentObject.selectAllAsCursor().org.tentackle.dbms.StatementIdselectAllStatementIdprepared statement ID forAbstractPersistentObject.selectAll().org.tentackle.dbms.StatementIdselectAllWithExpiredTableSerialsStatementIdprepared statement ID forAbstractPersistentObject.selectAllWithExpiredTableSerials(long).org.tentackle.dbms.StatementIdselectByInvertedNormTextCursorStatementIdprepared statement ID forAbstractPersistentObject.selectByNormTextAsCursor(java.lang.String).org.tentackle.dbms.StatementIdselectByInvertedNormTextStatementIdprepared statement ID forAbstractPersistentObject.selectByNormText(java.lang.String).org.tentackle.dbms.StatementIdselectByNormTextCursorStatementIdprepared statement ID forAbstractPersistentObject.selectByNormTextAsCursor(java.lang.String).org.tentackle.dbms.StatementIdselectByNormTextStatementIdprepared statement ID forAbstractPersistentObject.selectByNormText(java.lang.String).org.tentackle.dbms.StatementIdselectTokenLockStatementIdprepared statement ID for select inAbstractPersistentObject.updateTokenLock(org.tentackle.common.Timestamp, long, org.tentackle.common.Timestamp).PersistentObjectClassVariables<? super T,? super P>superClassVariablesThe classvariables of the parent class.
null if not inherited.java.lang.StringtableAliasThe table alias to be used in joined selects.PersistentObjectClassVariables<? super T,? super P>topSuperClassVariablesThe classvariables of the topmost parent class.
"this" if not inherited.org.tentackle.dbms.StatementIdtransferTokenLockStatementIdprepared statement ID forAbstractPersistentObject.transferTokenLock(long).org.tentackle.dbms.StatementIdupdateTokenLockOnlyStatementIdprepared statement ID forAbstractPersistentObject.updateTokenLockOnly().org.tentackle.dbms.StatementIdupdateTokenLockStatementId-
Fields inherited from class org.tentackle.dbms.DbObjectClassVariables
alwaysPrepare, classBaseName, classId, clazz, columnCount, deleteStatementId, dummyUpdateStatementId, expirationBacklog, foreignReferences, idSource, insertStatementId, remoteDelegateId, selectAllIdSerialStatementId, selectAllObjectsStatementId, selectExpiredTableSerials1StatementId, selectExpiredTableSerials2StatementId, selectForUpdateStatementId, selectMaxIdStatementId, selectMaxTableSerialStatementId, selectObjectStatementId, selectObjectsWithExpiredTableSerialsStatementId, selectSerialStatementId, tableName, updateAndSetSerialStatementId, updateSerialAndTableSerialStatementId, updateSerialStatementId, updateStatementId, updateTableSerialStatementId
-
-
Constructor Summary
Constructors Constructor Description PersistentObjectClassVariables(java.lang.Class<T> pdoClass, java.lang.Class<P> poClass, java.lang.String tableAlias)Constructs a classvariable.PersistentObjectClassVariables(java.lang.Class<T> pdoClass, java.lang.Class<P> poClass, java.lang.String tableAlias, PersistentObjectClassVariables<? super T,? super P> superClassVariables, java.util.List<Join<T,?>> eagerJoins)Constructs a classvariable.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancheckClassPermission(org.tentackle.pdo.DomainContext context, org.tentackle.security.Permission permission)Check security for this class.static <T extends org.tentackle.pdo.PersistentDomainObject<T>,P extends AbstractPersistentObject<T,P>>
PersistentObjectClassVariables<T,P>create(java.lang.Class<T> pdoClass, java.lang.Class<P> poClass, java.lang.String tableAlias)Creates a PDO classvariable.static <T extends org.tentackle.pdo.PersistentDomainObject<T>,P extends AbstractPersistentObject<T,P>>
PersistentObjectClassVariables<T,P>create(java.lang.Class<T> pdoClass, java.lang.Class<P> poClass, java.lang.String tableAlias, PersistentObjectClassVariables<? super T,? super P> superClassVariables, java.util.List<Join<T,?>> eagerJoins)Creates a PDO classvariable.protected intdetermineReferencePriority(java.lang.Class<? extends org.tentackle.dbms.AbstractDbObject<?>> clazz)protected java.lang.reflect.MethodfindSnapshotMethod(java.lang.String methodName, java.lang.Class<?> clazz)Finds a snapshot method.
Snapshot methods (AbstractPersistentObject.createAttributesInSnapshot(org.tentackle.persist.AbstractPersistentObject),AbstractPersistentObject.createComponentsInSnapshot(org.tentackle.persist.AbstractPersistentObject),AbstractPersistentObject.revertAttributesToSnapshot(org.tentackle.persist.AbstractPersistentObject)andAbstractPersistentObject.revertComponentsToSnapshot(org.tentackle.persist.AbstractPersistentObject)) take the snapshot object with the correct implementation type and are implemented at some implementation class.java.lang.StringgetColumnName(java.lang.String name)Gets the full column name with optional table alias.java.lang.reflect.MethodgetCreateAttributesInSnapshotMethod()Gets the method createAttributesInSnapshot of the persistence object.java.lang.reflect.MethodgetCreateComponentsInSnapshotMethod()Gets the method createComponentsInSnapshot of the persistence object.java.util.List<Join<T,?>>getEagerJoins()Gets the eager joins.java.lang.reflect.MethodgetRevertAttributesToSnapshotMethod()Gets the method revertAttributesToSnapshot of the persistence object.java.lang.reflect.MethodgetRevertComponentsToSnapshotMethod()Gets the method revertComponentsToSnapshot of the persistence object.java.lang.StringgetTableAlias()Gets the table alias.java.lang.StringgetTableName()Returns the tablename for this classvariable.PersistentObjectClassVariables<? super T,? super P>getTopSuperClassVariables()Returns the topmost classvariables.
Useful for multi-inheritance.booleanisAbstract()Returns whether the pdo class is abstract.booleanisEditAllowed(AbstractPersistentObject<?,?> object)Check the edit permission for a PDO.booleanisReadAllowed()Check the read security for this class in all contexts.booleanisReadAllowed(org.tentackle.pdo.DomainContext context)Check the read security for this class.booleanisReadAllowed(AbstractPersistentObject<?,?> object)Check the read permission for a PDO.booleanisReferenced(org.tentackle.dbms.Db db, long id)booleanisSecurityEnabled()booleanisViewAllowed(AbstractPersistentObject<?,?> object)Check the view permission for a PDO.booleanisWriteAllowed()Check the write security for this class in all contexts.booleanisWriteAllowed(org.tentackle.pdo.DomainContext context)Check the write security for this class.booleanisWriteAllowed(AbstractPersistentObject<?,?> object)Check the write permission for a PDO.java.lang.StringtoString()
-
-
-
Field Detail
-
PROPERTY_CHECKSECURITY
public static final java.lang.String PROPERTY_CHECKSECURITY
property key for the check security.- See Also:
- Constant Field Values
-
CLASSVARIABLES_NAME
public static final java.lang.String CLASSVARIABLES_NAME
the declared name of the static class variables.- See Also:
- Constant Field Values
-
pdoClass
public final java.lang.Class<T extends org.tentackle.pdo.PersistentDomainObject<T>> pdoClass
The associated PDO class (i.e. the interface)
-
methodCache
public final org.tentackle.pdo.PdoMethodCache<T extends org.tentackle.pdo.PersistentDomainObject<T>> methodCache
The PDO method invocation cache.
-
eagerJoins
public final java.util.List<Join<T extends org.tentackle.pdo.PersistentDomainObject<T>,?>> eagerJoins
The optional eager join.
-
pdoClassBaseName
public final java.lang.String pdoClassBaseName
the pdo base-classname.
-
tableAlias
public java.lang.String tableAlias
The table alias to be used in joined selects.
-
superClassVariables
public final PersistentObjectClassVariables<? super T extends org.tentackle.pdo.PersistentDomainObject<T>,? super P extends AbstractPersistentObject<T,P>> superClassVariables
The classvariables of the parent class.
null if not inherited.
-
topSuperClassVariables
public PersistentObjectClassVariables<? super T extends org.tentackle.pdo.PersistentDomainObject<T>,? super P extends AbstractPersistentObject<T,P>> topSuperClassVariables
The classvariables of the topmost parent class.
"this" if not inherited.
-
selectByNormTextStatementId
public final org.tentackle.dbms.StatementId selectByNormTextStatementId
prepared statement ID forAbstractPersistentObject.selectByNormText(java.lang.String).
-
selectByInvertedNormTextStatementId
public final org.tentackle.dbms.StatementId selectByInvertedNormTextStatementId
prepared statement ID forAbstractPersistentObject.selectByNormText(java.lang.String).
-
selectByNormTextCursorStatementId
public final org.tentackle.dbms.StatementId selectByNormTextCursorStatementId
prepared statement ID forAbstractPersistentObject.selectByNormTextAsCursor(java.lang.String).
-
selectByInvertedNormTextCursorStatementId
public final org.tentackle.dbms.StatementId selectByInvertedNormTextCursorStatementId
prepared statement ID forAbstractPersistentObject.selectByNormTextAsCursor(java.lang.String).
-
selectAllStatementId
public final org.tentackle.dbms.StatementId selectAllStatementId
prepared statement ID forAbstractPersistentObject.selectAll().
-
selectAllWithExpiredTableSerialsStatementId
public final org.tentackle.dbms.StatementId selectAllWithExpiredTableSerialsStatementId
prepared statement ID forAbstractPersistentObject.selectAllWithExpiredTableSerials(long).
-
selectAllCursorStatementId
public final org.tentackle.dbms.StatementId selectAllCursorStatementId
prepared statement ID forAbstractPersistentObject.selectAllAsCursor().
-
updateTokenLockStatementId
public final org.tentackle.dbms.StatementId updateTokenLockStatementId
-
updateTokenLockOnlyStatementId
public final org.tentackle.dbms.StatementId updateTokenLockOnlyStatementId
prepared statement ID forAbstractPersistentObject.updateTokenLockOnly().
-
selectTokenLockStatementId
public final org.tentackle.dbms.StatementId selectTokenLockStatementId
prepared statement ID for select inAbstractPersistentObject.updateTokenLock(org.tentackle.common.Timestamp, long, org.tentackle.common.Timestamp).
-
transferTokenLockStatementId
public final org.tentackle.dbms.StatementId transferTokenLockStatementId
prepared statement ID forAbstractPersistentObject.transferTokenLock(long).
-
-
Constructor Detail
-
PersistentObjectClassVariables
public PersistentObjectClassVariables(java.lang.Class<T> pdoClass, java.lang.Class<P> poClass, java.lang.String tableAlias, PersistentObjectClassVariables<? super T,? super P> superClassVariables, java.util.List<Join<T,?>> eagerJoins)
Constructs a classvariable.Notice: the superPoClass is necessary only in SINGLE and MULTI table inheritance configurations.
- Parameters:
pdoClass- the PDO's class (i.e. interface)poClass- the class of the persistence implementationtableAlias- the table alias to be used in joined selectssuperClassVariables- the class variables of the superclass, null if not inheritedeagerJoins- the optional eager joins, null of empty if none
-
PersistentObjectClassVariables
public PersistentObjectClassVariables(java.lang.Class<T> pdoClass, java.lang.Class<P> poClass, java.lang.String tableAlias)
Constructs a classvariable.- Parameters:
pdoClass- the PDO's class (i.e. interface)poClass- the class of the persistence implementationtableAlias- the table alias to be used in joined selects
-
-
Method Detail
-
create
public static <T extends org.tentackle.pdo.PersistentDomainObject<T>,P extends AbstractPersistentObject<T,P>> PersistentObjectClassVariables<T,P> create(java.lang.Class<T> pdoClass, java.lang.Class<P> poClass, java.lang.String tableAlias, PersistentObjectClassVariables<? super T,? super P> superClassVariables, java.util.List<Join<T,?>> eagerJoins)
Creates a PDO classvariable.- Type Parameters:
T- the PDO class typeP- the persistence class type- Parameters:
pdoClass- the PDO's class (i.e. interface)poClass- the class of the persistence implementationtableAlias- the table alias to be used in joined selectssuperClassVariables- the class variables of the superclass, null if not inheritedeagerJoins- the optional eager joins, null of empty if none
-
create
public static <T extends org.tentackle.pdo.PersistentDomainObject<T>,P extends AbstractPersistentObject<T,P>> PersistentObjectClassVariables<T,P> create(java.lang.Class<T> pdoClass, java.lang.Class<P> poClass, java.lang.String tableAlias)
Creates a PDO classvariable.- Type Parameters:
T- the PDO class typeP- the persistence class type- Parameters:
pdoClass- the PDO's class (i.e. interface)poClass- the class of the persistence implementationtableAlias- the table alias to be used in joined selects
-
getEagerJoins
public java.util.List<Join<T,?>> getEagerJoins()
Gets the eager joins.- Returns:
- the join, null or empty if none
-
getTableName
public java.lang.String getTableName()
Returns the tablename for this classvariable.If the class has no tablename, it is derived from its superclasses.
- Returns:
- the tablename, null if class does not map to any database table
-
getTableAlias
public java.lang.String getTableAlias()
Gets the table alias.If the class has no tablename, it is derived from its superclasses.
- Returns:
- the alias, null if class does not map to any 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
-
getTopSuperClassVariables
public PersistentObjectClassVariables<? super T,? super P> getTopSuperClassVariables()
Returns the topmost classvariables.
Useful for multi-inheritance.- Returns:
- the topmost variables, this if not inherited, never null
-
isSecurityEnabled
public boolean isSecurityEnabled()
-
isReferenced
public boolean isReferenced(org.tentackle.dbms.Db db, long id)- Overrides:
isReferencedin classorg.tentackle.dbms.DbObjectClassVariables<P extends AbstractPersistentObject<T,P>>
-
toString
public java.lang.String toString()
- Overrides:
toStringin classorg.tentackle.dbms.DbObjectClassVariables<P extends AbstractPersistentObject<T,P>>
-
isAbstract
public boolean isAbstract()
Returns whether the pdo class is abstract.- Returns:
- true if abstract
-
isReadAllowed
public boolean isReadAllowed(org.tentackle.pdo.DomainContext context)
Check the read security for this class. The implementation checks that the class rules will accept and that no object rule denies.Notice that
SecurityPersistenceImplobjects are always readable!- Parameters:
context- the current domain context, null = all- Returns:
- false if operation (select) is denied.
-
isReadAllowed
public boolean isReadAllowed()
Check the read security for this class in all contexts.- Returns:
- false if operation (select) is denied.
-
isWriteAllowed
public boolean isWriteAllowed(org.tentackle.pdo.DomainContext context)
Check the write security for this class. The implementation checks that the class rules will accept and that no object rule denies.- Parameters:
context- the current domain context, null = all- Returns:
- false if operation (delete, update or insert) is denied.
-
isWriteAllowed
public boolean isWriteAllowed()
Check the write security for this class in all contexts.- Returns:
- false if operation (delete, update or insert) is denied.
-
isReadAllowed
public boolean isReadAllowed(AbstractPersistentObject<?,?> object)
Check the read permission for a PDO.Components are readable if their root-entity is readable.
- Parameters:
object- the object to check the security rules for.- Returns:
- false if operation (select) is denied.
-
isWriteAllowed
public boolean isWriteAllowed(AbstractPersistentObject<?,?> object)
Check the write permission for a PDO.Only root-entities are writable. Components are not writable by default (because only the root can be persisted).
Notice that the persistence layer will not invoke isWriteAllowed on components, because the root is already checked when saving or deleting a PDO. Remember that only root entities can be persisted by the application!
- Parameters:
object- the object to check the security rules for.- Returns:
- false if operation is denied
-
isViewAllowed
public boolean isViewAllowed(AbstractPersistentObject<?,?> object)
Check the view permission for a PDO.Components are viewable if their root-entity is viewable.
- Parameters:
object- the object to check the security rules for.- Returns:
- false if operation is denied
-
isEditAllowed
public boolean isEditAllowed(AbstractPersistentObject<?,?> object)
Check the edit permission for a PDO.Only root-entities are editable. Components are not editable by default (because only the root can be persisted).
- Parameters:
object- the object to check the security rules for.- Returns:
- false if operation is denied
-
getCreateAttributesInSnapshotMethod
public java.lang.reflect.Method getCreateAttributesInSnapshotMethod() throws java.lang.NoSuchMethodExceptionGets the method createAttributesInSnapshot of the persistence object.- Returns:
- the method
- Throws:
java.lang.NoSuchMethodException- if not found
-
getRevertAttributesToSnapshotMethod
public java.lang.reflect.Method getRevertAttributesToSnapshotMethod() throws java.lang.NoSuchMethodExceptionGets the method revertAttributesToSnapshot of the persistence object.- Returns:
- the method
- Throws:
java.lang.NoSuchMethodException- if not found
-
getCreateComponentsInSnapshotMethod
public java.lang.reflect.Method getCreateComponentsInSnapshotMethod() throws java.lang.NoSuchMethodExceptionGets the method createComponentsInSnapshot of the persistence object.- Returns:
- the method
- Throws:
java.lang.NoSuchMethodException- if not found
-
getRevertComponentsToSnapshotMethod
public java.lang.reflect.Method getRevertComponentsToSnapshotMethod() throws java.lang.NoSuchMethodExceptionGets the method revertComponentsToSnapshot of the persistence object.- Returns:
- the method
- Throws:
java.lang.NoSuchMethodException- if not found
-
findSnapshotMethod
protected java.lang.reflect.Method findSnapshotMethod(java.lang.String methodName, java.lang.Class<?> clazz) throws java.lang.NoSuchMethodExceptionFinds a snapshot method.
Snapshot methods (AbstractPersistentObject.createAttributesInSnapshot(org.tentackle.persist.AbstractPersistentObject),AbstractPersistentObject.createComponentsInSnapshot(org.tentackle.persist.AbstractPersistentObject),AbstractPersistentObject.revertAttributesToSnapshot(org.tentackle.persist.AbstractPersistentObject)andAbstractPersistentObject.revertComponentsToSnapshot(org.tentackle.persist.AbstractPersistentObject)) take the snapshot object with the correct implementation type and are implemented at some implementation class. This method finds the most specific snapshot-method along the inheritance hierarchy.- Parameters:
methodName- the snapshot method nameclazz- the implementation class- Returns:
- the method
- Throws:
java.lang.NoSuchMethodException- if no such method found
-
determineReferencePriority
protected int determineReferencePriority(java.lang.Class<? extends org.tentackle.dbms.AbstractDbObject<?>> clazz)
Overridden to determine the priority according to the presence of a cache:
- high: class provides a preloading cache (low volume data, usually master data)
- medium: class provides a non-preloading cache (medium volume data)
- low: class provides no cache (high volume, usually transaction data)
- Overrides:
determineReferencePriorityin classorg.tentackle.dbms.DbObjectClassVariables<P extends AbstractPersistentObject<T,P>>
-
checkClassPermission
protected boolean checkClassPermission(org.tentackle.pdo.DomainContext context, org.tentackle.security.Permission permission)Check security for this class.- Parameters:
context- the domain contextpermission- the permission- Returns:
- true if accepted
-
-