S
- row class of table that is source of cascadeT
- row class of table that is target of cascadepublic abstract class CascadeOperation<S,T>
extends java.lang.Object
implements java.lang.AutoCloseable
Constructor and Description |
---|
CascadeOperation(Table<S> sourceTable,
RowField<S,?> targetField,
Table<T> targetTable,
java.lang.Class<?> cascadeOperationClass)
Constructs for field and table to be affected by cascade.
|
CascadeOperation(Table<S> sourceTable,
SormulaField<S,?> targetField,
Table<T> targetTable,
java.lang.Class<?> cascadeOperationClass)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
cascade(S sourceRow)
Performs cascade operation.
|
abstract void |
close()
Cleans up by closing any JDBC resources.
|
protected SqlOperation<?> |
createOperation()
Creates new instance of sql operation from
cascadeOperationClass supplied in the
constructor. |
java.lang.String |
getForeignKeyReferenceFieldName()
Gets the name of the foreign key reference field in the target (child) rows.
|
java.lang.String[] |
getForeignKeyValueFieldNames()
Gets the field key value field names in target (child) rows.
|
int |
getKeyFieldCount()
Gets number of key fields.
|
java.util.Map<java.lang.String,java.lang.Object> |
getNamedParameterMap()
Gets the map of named parameters.
|
java.lang.String[] |
getRequiredCascades()
Gets required cascade names set with
setRequiredCascades(String...) . |
S |
getSourceRow()
Source row of cascade set by
cascade(Object) . |
Table<S> |
getSourceTable()
Gets
Table that originates (is source of) cascade. |
SormulaField<S,?> |
getTargetField()
Gets target field as
SormulaField . |
protected java.util.List<SormulaField<T,java.lang.Object>> |
getTargetForeignKeyValueFieldList()
Note: return type will be List
|
Table<T> |
getTargetTable() |
boolean |
isPost() |
void |
prepare()
Prepares operation by initializing JDBC statements.
|
protected void |
prepareForeignKeyReferenceField()
Prepares accessor that will set foreign key reference on cascaded target rows as defined by
Cascade.foreignKeyReferenceField() . |
protected void |
prepareForeignKeyValueFields()
Prepares accessors that will set foreign key(s) on cascaded target rows as defined by
Cascade.foreignKeyValueFields() . |
void |
setForeignKeyFieldNames(java.lang.String[] foreignKeyFieldNames)
Sets the name of fields that contain the foreign key values in target (child) rows.
|
protected void |
setForeignKeyReference(java.util.Collection<T> rows)
Sets the foreign key reference in target (child) rows as source (parent) row.
|
protected void |
setForeignKeyReference(T row)
Sets the foreign key reference in target (child) row as source (parent) row.
|
void |
setForeignKeyReferenceFieldName(java.lang.String foreignKeyReferenceFieldName)
Sets the field name that contains a reference to the foreign key object in target (child) rows.
|
protected void |
setForeignKeyValues(java.util.Collection<T> rows)
Sets the foreign key(s) in target (child) rows from primary key(s) in source (parent) row.
|
protected void |
setForeignKeyValues(T row)
Sets the foreign key(s) in target (child) row from primary key(s) in source (parent) row.
|
void |
setNamedParameterMap(java.util.Map<java.lang.String,java.lang.Object> namedParameterMap)
Sets the map of named parameters.
|
void |
setPost(boolean post)
Sets when to perform the cascade.
|
void |
setRequiredCascades(java.lang.String... cascadeNames)
Sets required cascade names to use.
|
@Deprecated public CascadeOperation(Table<S> sourceTable, SormulaField<S,?> targetField, Table<T> targetTable, java.lang.Class<?> cascadeOperationClass)
sourceTable
- cascade originates on row from this tabletargetField
- in source row to be affected by cascade operationtargetTable
- sormula table that will be cascadedcascadeOperationClass
- class of cascade operation (used to create new instance)
is to be performed before source row operationpublic CascadeOperation(Table<S> sourceTable, RowField<S,?> targetField, Table<T> targetTable, java.lang.Class<?> cascadeOperationClass)
sourceTable
- cascade originates on row from this tabletargetField
- in source row to be affected by cascade operationtargetTable
- sormula table that will be cascadedcascadeOperationClass
- class of cascade operation (used to create new instance)
is to be performed before source row operationpublic void setPost(boolean post)
post
- true if cascade is to be performed after select/execute;
false if cascade is to be performed before select/executepublic boolean isPost()
public java.lang.String[] getForeignKeyValueFieldNames()
public void setForeignKeyFieldNames(java.lang.String[] foreignKeyFieldNames)
foreignKeyFieldNames
- field names from cascade annotation foreignKeyValueFieldsCascade.foreignKeyValueFields()
,
OneToManyCascade.foreignKeyValueFields()
,
OneToOneCascade.foreignKeyValueFields()
public java.lang.String getForeignKeyReferenceFieldName()
public void setForeignKeyReferenceFieldName(java.lang.String foreignKeyReferenceFieldName)
foreignKeyReferenceFieldName
- field name of foreign key reference from cascade
annotation foreignKeyReferenceFieldCascade.foreignKeyReferenceField()
,
OneToManyCascade.foreignKeyReferenceField()
,
OneToOneCascade.foreignKeyReferenceField()
public void setRequiredCascades(java.lang.String... cascadeNames)
SqlOperation.setRequiredCascades(String...)
for
details.cascadeNames
- names of cascades that will be executedpublic java.lang.String[] getRequiredCascades()
setRequiredCascades(String...)
.public int getKeyFieldCount()
public java.util.Map<java.lang.String,java.lang.Object> getNamedParameterMap()
SqlOperation.getParameter(String)
,
SqlOperation.setParameter(String, Object)
,
SqlOperation.getNamedParameterMap()
public void setNamedParameterMap(java.util.Map<java.lang.String,java.lang.Object> namedParameterMap)
namedParameterMap
- map of name to value or null if no named parametersSqlOperation.getParameter(String)
,
SqlOperation.setParameter(String, Object)
,
SqlOperation.getNamedParameterMap()
public void cascade(S sourceRow) throws OperationException
sourceRow
- row in parent table that was source the cascadeOperationException
- if errorpublic void prepare() throws OperationException
prepareForeignKeyValueFields()
. Subclasses should override
to perform additional preparation.OperationException
- if errorpublic abstract void close() throws OperationException
close
in interface java.lang.AutoCloseable
OperationException
- if errorpublic Table<S> getSourceTable()
Table
that originates (is source of) cascade.public SormulaField<S,?> getTargetField()
SormulaField
.public S getSourceRow()
cascade(Object)
.protected SqlOperation<?> createOperation() throws OperationException
cascadeOperationClass
supplied in the
constructor.OperationException
protected void prepareForeignKeyValueFields() throws OperationException
Cascade.foreignKeyValueFields()
.OperationException
- if errorprotected void prepareForeignKeyReferenceField() throws OperationException
Cascade.foreignKeyReferenceField()
.OperationException
- if errorprotected void setForeignKeyValues(T row) throws OperationException
row
- target (child) row to affectOperationException
- if errorprotected void setForeignKeyValues(java.util.Collection<T> rows) throws OperationException
rows
- target (child) rows to affectOperationException
- if errorprotected void setForeignKeyReference(T row) throws OperationException
row
- target (child) row to affectOperationException
- if errorprotected void setForeignKeyReference(java.util.Collection<T> rows) throws OperationException
rows
- target (child) rows to affectOperationException
- if errorprotected java.util.List<SormulaField<T,java.lang.Object>> getTargetForeignKeyValueFieldList()