Annotation Interface SCD


@Target(TYPE) @Retention(RUNTIME) @Documented public @interface SCD

The SCD (Slowly Changing Dimension) implementation support annotation. This annotation is used to assign SCD persistence to an entity. When using SCD, a history log is written about the entity, which can be later used. Static data from it can be queried with the appropriate methods.

In JBStrap, the entities can be marked with the SCD annotation. Only entities that have the SCD annotation will have other annotations interpreted on them (ie: if an entity does not have the SCD annotation, all of its other annotations will be ignored). This is the SCD annotation's only role, it is used to define the entity's handling mechanism.
Other annotations, that are interpreted on the fields that have the SCD annotation:

  • ValidFrom: The entity's validity start date. Applicable on Date type fields.
  • ValidTo: The entity's validity end date. Applicable on Date type fields.
  • ActiveFlag: Determines if the entity is flagged as active. Applicable on Boolean, String, Number type fields.
  • EntityId: The entity's first version's primary key. Useful for queries. If it's a complex key, it's applicable on String type fields, otherwise it's applicable on fields that have the same type as the current entity's primary key.
The same annotation can be placed on multiple fields. In an entity, an annotation can be used multiple times. If a field has two SCD annotations, the field value will be overwritten by the value of the last processed annotation

The field level SCD annotation load order:
When creating a new entity :
In the case of a new entity, the ValidFrom filed value will be filled with the current date, the ActiveFlag field value will be filled with true or "Y" or 1 (depending on the field type) and the EntityId field value will be filled with the current saved entity's primary key. When modifying an existing entity:
In the case of modifying an existing entity, it's last modified record will be queried first. The received record's ValidTo field value will be filled with the current date, the ActiveFlag field value will be false or "N" or 0, depending on the field type. In the next step, the entity's last modified record's ValidFrom field will be filled with the current date, the ActiveFlag field value will be true or "Y" or 1 (depending on the entity field's java type). The EntityId field value will be the entity's first saved record's primary key. When deleting an existing record:
During deletion, no real deletion takes place, the last modified entity record will be modified. The ValidTo field value will be filled with the current date. The ActiveFlag field value will be false or "N" or 0 (depending on the entity field's java type).

Since:
4.0
Author:
JBStrap
See Also: