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(SqlOperation<S> sourceOperation,
RowField<S,?> targetField,
Table<T> targetTable,
java.lang.Class<?> cascadeSqlOperationClass)
Constructs from source operation and targets of the cascade.
|
CascadeOperation(Table<S> sourceTable,
RowField<S,?> targetField,
Table<T> targetTable,
java.lang.Class<?> cascadeSqlOperationClass)
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
cascadeSqlOperationClass supplied in the
constructor. |
protected void |
deriveSqlOperationAttributes()
Sets the sql operation attributes that are the same as source attributes for
all levels.
|
int |
getDepth()
Gets the depth of the cascade graph relative to the root cascade operation.
|
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()
If constructed with
CascadeOperation(Table, RowField, Table, Class) then
gets required cascade names set with setRequiredCascades(String...) . |
SqlOperation<S> |
getSourceOperation()
Gets operation that triggered this cascade.
|
S |
getSourceRow()
Source row of cascade set by
cascade(Object) . |
Table<S> |
getSourceTable()
Gets
Table that originates (is source of) cascade. |
RowField<S,?> |
getTargetField()
Gets target field as
RowField . |
protected java.util.List<RowField<T,java.lang.Object>> |
getTargetForeignKeyValueFieldList() |
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 |
setDepth(int depth)
Deprecated.
no need to set depth since it is always source operation level + 1
|
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)
Deprecated.
no longer needed since determined by
SqlOperation.getNamedParameterMap() of source operation |
void |
setPost(boolean post)
Sets when to perform the cascade.
|
void |
setRequiredCascades(java.lang.String... cascadeNames)
Deprecated.
no longer needed since determined by
SqlOperation.getRequiredCascades() of source operation |
@Deprecated public CascadeOperation(Table<S> sourceTable, RowField<S,?> targetField, Table<T> targetTable, java.lang.Class<?> cascadeSqlOperationClass)
CascadeOperation(SqlOperation, RowField, Table, Class)
sourceTable
- cascade originates on row from this tabletargetField
- in source row to be affected by cascade operationtargetTable
- sormula table that will be cascadedcascadeSqlOperationClass
- class of cascade operation (used to create new instance)
is to be performed before source row operationpublic CascadeOperation(SqlOperation<S> sourceOperation, RowField<S,?> targetField, Table<T> targetTable, java.lang.Class<?> cascadeSqlOperationClass)
sourceOperation
- operation where cascade originatestargetField
- in source row to be affected by cascade operationtargetTable
- sormula table that will be cascadedcascadeSqlOperationClass
- 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 int getDepth()
@Deprecated public void setDepth(int depth)
SqlOperation
when preparing cascades.depth
- 0..npublic 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()
@Deprecated public void setRequiredCascades(java.lang.String... cascadeNames)
SqlOperation.getRequiredCascades()
of source operationSqlOperation.setRequiredCascades(String...)
for
details.cascadeNames
- names of cascades that will be executedpublic java.lang.String[] getRequiredCascades()
CascadeOperation(Table, RowField, Table, Class)
then
gets required cascade names set with setRequiredCascades(String...)
.
If constructed with CascadeOperation(SqlOperation, RowField, Table, Class)
then
returns source operation SqlOperation.getRequiredCascades()
.
public int getKeyFieldCount()
public java.util.Map<java.lang.String,java.lang.Object> getNamedParameterMap()
SqlOperation.getParameter(String)
,
SqlOperation.setParameter(String, Object)
,
SqlOperation.getNamedParameterMap()
@Deprecated public void setNamedParameterMap(java.util.Map<java.lang.String,java.lang.Object> namedParameterMap)
SqlOperation.getNamedParameterMap()
of source operationnamedParameterMap
- 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 SqlOperation<S> getSourceOperation()
public Table<S> getSourceTable()
Table
that originates (is source of) cascade.public RowField<S,?> getTargetField()
RowField
.public S getSourceRow()
cascade(Object)
.protected SqlOperation<?> createOperation() throws OperationException
cascadeSqlOperationClass
supplied in the
constructor.SqlOperation
that will be used for cascadeOperationException
- if errorprotected void deriveSqlOperationAttributes()
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 error