Class PersistentObjectClassVariables<T extends PersistentDomainObject<T>,P extends AbstractPersistentObject<T,P>>
- Type Parameters:
T- the PDO class typeP- the persistence class type
DbObjectClassVariables for AbstractPersistentObjects.- Author:
- harald
-
Nested Class Summary
Nested classes/interfaces inherited from class org.tentackle.dbms.DbObjectClassVariables
DbObjectClassVariables.ForeignReference -
Field Summary
FieldsModifier and TypeFieldDescriptionThe optional eager join as defined in the model.final PdoMethodCache<T>The PDO method invocation cache.The associated PDO class (i.e.final Stringthe pdo base-classname.static final Stringproperty key for the check security.final StatementIdprepared statement ID forAbstractPersistentObject.selectAllAsCursor().final StatementIdprepared statement ID forAbstractPersistentObject.selectAll().final StatementIdprepared statement ID forAbstractPersistentObject.selectAllWithExpiredTableSerials(long).final StatementIdprepared statement ID forAbstractPersistentObject.selectByNormTextAsCursor(java.lang.String).final StatementIdprepared statement ID forAbstractPersistentObject.selectByNormText(java.lang.String).final StatementIdprepared statement ID forAbstractPersistentObject.selectByNormTextAsCursor(java.lang.String).final StatementIdprepared statement ID forAbstractPersistentObject.selectByNormText(java.lang.String).final StatementIdprepared statement ID forAbstractPersistentObject.selectLatest(long, int).final StatementIdprepared statement ID for select inAbstractPersistentObject.updateTokenLock(org.tentackle.common.Timestamp, long, org.tentackle.common.Timestamp).final PersistentObjectClassVariables<? super T,? super P> The classvariables of the parent class.
null if not inherited.final StringThe table alias to be used in joined selects.final StatementIdprepared statement ID forAbstractPersistentObject.transferTokenLock(long).final StatementIdprepared statement ID forAbstractPersistentObject.updateTokenLockOnly().final StatementIdFields 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 -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancheckClassPermission(DomainContext context, Permission permission) Check security for this class.static <T extends PersistentDomainObject<T>,P extends AbstractPersistentObject<T, P>>
PersistentObjectClassVariables<T,P> Creates a PDO class variable.static <T extends PersistentDomainObject<T>,P extends AbstractPersistentObject<T, P>>
PersistentObjectClassVariables<T,P> create(Class<T> pdoClass, Class<P> poClass, String tableAlias, PersistentObjectClassVariables<? super T, ? super P> superClassVariables, List<Join<T, ?>> eagerJoins) Creates a PDO classvariable.createSqlClassIdCondition(List<Integer> classIds, boolean withAlias) Creates the SQL string used in WHERE-clauses for inherited entities.protected intdetermineReferencePriority(Class<? extends AbstractDbObject<?>> clazz) protected MethodfindSnapshotMethod(String methodName, Class<?> clazz) Finds a snapshot method.
Snapshot methods (AbstractPersistentObject.createAttributesInSnapshot(AbstractPersistentObject),AbstractPersistentObject.createComponentsInSnapshot(AbstractPersistentObject),AbstractPersistentObject.revertAttributesToSnapshot(AbstractPersistentObject)andAbstractPersistentObject.revertComponentsToSnapshot(AbstractPersistentObject)) take the snapshot object with the correct implementation type and are implemented at some implementation class.getColumnName(String name) Gets the full column name with optional table alias.getColumnNames(Supplier<List<String>> columnNamesSupplier) Gets the comma-separated list of column names with table alias.getColumnNames(List<String> columnNames) Gets the comma-separated list of column names with table alias.Gets the method createAttributesInSnapshot of the persistence object.Gets the method createComponentsInSnapshot of the persistence object.Gets the effective eager joins.Gets the method revertAttributesToSnapshot of the persistence object.Gets the method revertComponentsToSnapshot of the persistence object.getSqlClassIdCondition(List<Integer> classIds) Gets the SQL string used in WHERE-clauses for single table inheritance entities.Gets the table alias.Returns the tablename for this classvariable.PersistentObjectClassVariables<? super T,? super P> Returns the topmost classvariables.
Useful for multi-inheritance.booleanReturns whether the pdo class is abstract.booleanisEditAllowed(AbstractPersistentObject<?, ?> object) Check the edit permission for a PDO.booleanCheck the read security for this class in all contexts.booleanisReadAllowed(DomainContext context) Check the read security for this class.booleanisReadAllowed(AbstractPersistentObject<?, ?> object) Check the read permission for a PDO.booleanisReferenced(Db db, long id) booleanbooleanisViewAllowed(AbstractPersistentObject<?, ?> object) Check the view permission for a PDO.booleanCheck the write-security for this class in all contexts.booleanisWriteAllowed(DomainContext context) Check the write-security for this class.booleanisWriteAllowed(AbstractPersistentObject<?, ?> object) Check the write-permission for a PDO.toString()Methods inherited from class org.tentackle.dbms.DbObjectClassVariables
addReferencingClass, create, create, createBacklog, getIdSource, getProperties, getProperty, getRemoteDelegate, getRemoteDelegateId, getVariables, isReferencedImpl, putProperty, putVariables, removeReferencingClass
-
Field Details
-
PROPERTY_CHECKSECURITY
property key for the check security.- See Also:
-
pdoClass
The associated PDO class (i.e. the interface) -
methodCache
The PDO method invocation cache. -
eagerJoins
The optional eager join as defined in the model. -
pdoClassBaseName
the pdo base-classname. -
tableAlias
The table alias to be used in joined selects. -
superClassVariables
public final PersistentObjectClassVariables<? super T extends PersistentDomainObject<T>,? super P extends AbstractPersistentObject<T, superClassVariablesP>> The classvariables of the parent class.
null if not inherited. -
selectByNormTextStatementId
prepared statement ID forAbstractPersistentObject.selectByNormText(java.lang.String). -
selectByInvertedNormTextStatementId
prepared statement ID forAbstractPersistentObject.selectByNormText(java.lang.String). -
selectByNormTextCursorStatementId
prepared statement ID forAbstractPersistentObject.selectByNormTextAsCursor(java.lang.String). -
selectByInvertedNormTextCursorStatementId
prepared statement ID forAbstractPersistentObject.selectByNormTextAsCursor(java.lang.String). -
selectAllStatementId
prepared statement ID forAbstractPersistentObject.selectAll(). -
selectAllWithExpiredTableSerialsStatementId
prepared statement ID forAbstractPersistentObject.selectAllWithExpiredTableSerials(long). -
selectLatestStatementId
prepared statement ID forAbstractPersistentObject.selectLatest(long, int). -
selectAllCursorStatementId
prepared statement ID forAbstractPersistentObject.selectAllAsCursor(). -
updateTokenLockStatementId
-
updateTokenLockOnlyStatementId
prepared statement ID forAbstractPersistentObject.updateTokenLockOnly(). -
selectTokenLockStatementId
prepared statement ID for select inAbstractPersistentObject.updateTokenLock(org.tentackle.common.Timestamp, long, org.tentackle.common.Timestamp). -
transferTokenLockStatementId
prepared statement ID forAbstractPersistentObject.transferTokenLock(long).
-
-
Constructor Details
-
PersistentObjectClassVariables
public PersistentObjectClassVariables(Class<T> pdoClass, Class<P> poClass, String tableAlias, PersistentObjectClassVariables<? super T, ? super P> superClassVariables, 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
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 Details
-
create
public static <T extends PersistentDomainObject<T>,P extends AbstractPersistentObject<T, PersistentObjectClassVariables<T,P>> P> create(Class<T> pdoClass, Class<P> poClass, String tableAlias, PersistentObjectClassVariables<? super T, ? super P> superClassVariables, 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 PersistentDomainObject<T>,P extends AbstractPersistentObject<T, PersistentObjectClassVariables<T,P>> P> create(Class<T> pdoClass, Class<P> poClass, String tableAlias) Creates a PDO class variable.- 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
-
getColumnNames
Gets the comma-separated list of column names with table alias.- Parameters:
columnNamesSupplier- the supplier for the list of column names- Returns:
- the partial SQL string
-
getColumnNames
Gets the comma-separated list of column names with table alias.- Parameters:
columnNames- the list of column names- Returns:
- the partial SQL string
-
getSqlClassIdCondition
Gets the SQL string used in WHERE-clauses for single table inheritance entities.- Parameters:
classIds- the valid class IDs, null or empty if none- Returns:
- the SQL string, empty if no such condition necessary
-
createSqlClassIdCondition
Creates the SQL string used in WHERE-clauses for inherited entities.- Parameters:
classIds- the valid class IDs, null or empty if nonewithAlias- prepend classID column name with table alias- Returns:
- the SQL string, empty if no such condition necessary
-
getEagerJoins
Gets the effective eager joins.- Returns:
- the joins, null if none
-
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
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
Gets the full column name with optional table alias.- Parameters:
name- the short name- Returns:
- the full name
-
getTopSuperClassVariables
Returns the topmost classvariables.
Useful for multi-inheritance.- Returns:
- the topmost variables, this if not inherited, never null
-
isSecurityEnabled
public boolean isSecurityEnabled() -
isReferenced
- Overrides:
isReferencedin classDbObjectClassVariables<P extends AbstractPersistentObject<T,P>>
-
toString
- Overrides:
toStringin classDbObjectClassVariables<P extends AbstractPersistentObject<T,P>>
-
isAbstract
public boolean isAbstract()Returns whether the pdo class is abstract.- Returns:
- true if abstract
-
isReadAllowed
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
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
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
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
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
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
Gets the method createAttributesInSnapshot of the persistence object.- Returns:
- the method
- Throws:
NoSuchMethodException- if not found
-
getRevertAttributesToSnapshotMethod
Gets the method revertAttributesToSnapshot of the persistence object.- Returns:
- the method
- Throws:
NoSuchMethodException- if not found
-
getCreateComponentsInSnapshotMethod
Gets the method createComponentsInSnapshot of the persistence object.- Returns:
- the method
- Throws:
NoSuchMethodException- if not found
-
getRevertComponentsToSnapshotMethod
Gets the method revertComponentsToSnapshot of the persistence object.- Returns:
- the method
- Throws:
NoSuchMethodException- if not found
-
findSnapshotMethod
Finds a snapshot method.
Snapshot methods (AbstractPersistentObject.createAttributesInSnapshot(AbstractPersistentObject),AbstractPersistentObject.createComponentsInSnapshot(AbstractPersistentObject),AbstractPersistentObject.revertAttributesToSnapshot(AbstractPersistentObject)andAbstractPersistentObject.revertComponentsToSnapshot(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:
NoSuchMethodException- if no such method found
-
determineReferencePriority
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 classDbObjectClassVariables<P extends AbstractPersistentObject<T,P>>
-
checkClassPermission
Check security for this class.- Parameters:
context- the domain contextpermission- the permission- Returns:
- true if accepted
-