org.sormula.annotation.cascade
Annotation Type Cascade


@Retention(value=RUNTIME)
@Target(value=FIELD)
public @interface Cascade

A general purpose cascade annotation. It may be used on any class variable that is either scalar or a collection. Use this as an alternative to OneToManyCascade or OneToOneCascade.

More than one operation is allowed per field even though it is not likely that you would need more than one. selects(), updates(), inserts(), and deletes() accepts arrays which allow an empty array to mean "do nothing".

Since:
1.0
Author:
Jeff Miller

Optional Element Summary
 DeleteCascade[] deletes
          Delete cascade operations for target fields.
 InsertCascade[] inserts
          Insert cascade operations for target fields.
 SaveCascade[] saves
          Save cascade operations for target fields.
 SelectCascade[] selects
          Select cascade operations for target fields.
 java.lang.Class<?> targetClass
          Class type of target field to affect.
 UpdateCascade[] updates
          Update cascade operations for target fields.
 

targetClass

public abstract java.lang.Class<?> targetClass
Class type of target field to affect. Used as parameter to Database.getTable(Class) to get table for cascade operation. targetClass() is optional for scalar fields since target class can be obtained from target field at runtime.

For nonscalar target field types, like arrays, Collection types, and Map types, targetClass can be determined from the field. Array types can be determined through Class.getComponentType(). For collections and maps, target class can be determined through the parameterized type with Field.getGenericType() if the generic type is not parameterized. For complex parameterized types, target class must be specified.

The following are examples of fields where targetClass=Something.class is optional in cascade annotations because it can be determined through reflection:

 Something scalar;
 Something[] array;
 List<Something> list;
 Map<String, Something> map;
 

Returns:
class of field that is involved in cascade; Object.class to indicate that class is to be obtained from scalar field at runtime by relfection
Default:
java.lang.Object.class

selects

public abstract SelectCascade[] selects
Select cascade operations for target fields. Use empty array to perform no select cascades.

Returns:
select annotations for cascade
Default:
{}

inserts

public abstract InsertCascade[] inserts
Insert cascade operations for target fields. Use empty array to perform no insert cascades.

Returns:
insert annotations for cascade
Default:
{}

updates

public abstract UpdateCascade[] updates
Update cascade operations for target fields. Use empty array to perform no update cascades.

Returns:
update annotations for cascade
Default:
{}

saves

public abstract SaveCascade[] saves
Save cascade operations for target fields. Use empty array to perform no update cascades.

Returns:
update annotations for cascade
Since:
1.9.3 and 2.3.3
Default:
{}

deletes

public abstract DeleteCascade[] deletes
Delete cascade operations for target fields. Use empty array to perform no delete cascades.

Returns:
delete annotations for cascade
Default:
{}