|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.sormula.operation.SqlOperation<R> org.sormula.operation.ModifyOperation<R> org.sormula.operation.SaveOperation<R>
R
- class type which contains members for columns of a row in a tablepublic class SaveOperation<R>
SQL update or insert operation for row of type R. Rows are updated if they exist
in the database or inserted if they are new rows. Cascades are performed based upon
Cascade.saves()
, OneToManyCascade.saves()
, or OneToOneCascade.saves()
.
Inserts and updates are performed by class members of type InsertOperation
and UpdateOperation
. Since most of the work is delegated to InsertOperation
and UpdateOperation
, not all methods of base class ModifyOperation
are
used. All of the methods in SaveOperation may be safely overridden but some subclass methods
may not be used.
Constructor Summary | |
---|---|
SaveOperation(Table<R> table)
Constructs to update by primary key or insert if update fails. |
|
SaveOperation(Table<R> table,
java.lang.String whereConditionName)
Constructs to update by where condition or insert if update fails. |
Method Summary | |
---|---|
void |
close()
Cleans up after operation is no longer needed. |
void |
execute()
Executes operation for all row parameters using current prepared statement. |
protected void |
postExecute(R row)
Invoked after JDBC execute. |
protected void |
postExecuteCascade(R row)
Invoked after JDBC execute. |
protected void |
preExecute(R row)
Invoked prior to JDBC execute. |
protected void |
preExecuteCascade(R row)
Invoked prior to JDBC execute. |
protected java.util.List<CascadeOperation<R,?>> |
prepareCascades(java.lang.reflect.Field field)
Creates save cascade operations based upon the save annotations for field. |
int |
save(java.lang.Object... parameters)
Saves rows based upon parameters. |
int |
save(R row)
Saves a row. |
int |
saveAll(java.util.Collection<R> rows)
Saves all rows in collection. |
Methods inherited from class org.sormula.operation.ModifyOperation |
---|
getRowsAffected, isBatch, modify, modify, modifyAll, setBatch, setParameters, setRow, setRows, setRows, setRows, setRowsAffected |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SaveOperation(Table<R> table) throws OperationException
table
- update/insert to this table
OperationException
- if errorpublic SaveOperation(Table<R> table, java.lang.String whereConditionName) throws OperationException
table
- update/insert to this tablewhereConditionName
- name of where condition to use for update ("primaryKey" to update
by primary key; empty string to update all rows in table)
OperationException
- if errorMethod Detail |
---|
public void close() throws OperationException
ModifyOperation
CascadeOperation
objects. This method should
be invoked when operation is no longer needed for proper JDBC clean up.
close
in class ModifyOperation<R>
OperationException
- if errorpublic int save(R row) throws OperationException
ModifyOperation.modify(Object)
.
row
- row to use for parameters
ModifyOperation.getRowsAffected()
OperationException
- if errorpublic int saveAll(java.util.Collection<R> rows) throws OperationException
ModifyOperation.modifyAll(Collection)
.
rows
- collection of rows to use as parameters
ModifyOperation.getRowsAffected()
OperationException
- if errorpublic int save(java.lang.Object... parameters) throws OperationException
ModifyOperation.modify(Object...)
.
parameters
- operation parameters as objects (see ModifyOperation.setParameters(Object...)
)
OperationException
- if errorpublic void execute() throws OperationException
ModifyOperation
ModifyOperation.getRowsAffected()
will return the sum of all rows affected.
execute
in class ModifyOperation<R>
OperationException
- if errorprotected java.util.List<CascadeOperation<R,?>> prepareCascades(java.lang.reflect.Field field) throws OperationException
prepareCascades
in class SqlOperation<R>
field
- annotation is for this field of row class R
OperationException
- if errorprotected void preExecute(R row) throws OperationException
ModifyOperation.setParameters(Object...)
is used since no row is available.
preExecute
in class ModifyOperation<R>
row
- row for JDBC execute
OperationException
- if errorprotected void postExecute(R row) throws OperationException
ModifyOperation.setParameters(Object...)
is used since no row is available.
postExecute
in class ModifyOperation<R>
row
- row for JDBC execute
OperationException
- if errorprotected void preExecuteCascade(R row) throws OperationException
preExecuteCascade
in class ModifyOperation<R>
row
- row for JDBC execute
OperationException
InsertCascade.post()
,
UpdateCascade.post()
,
SaveCascade.post()
,
DeleteCascade.post()
protected void postExecuteCascade(R row) throws OperationException
postExecuteCascade
in class ModifyOperation<R>
row
- row for JDBC execute
OperationException
InsertCascade.post()
,
UpdateCascade.post()
,
SaveCascade.post()
,
DeleteCascade.post()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |