com.ibm.pdq.annotation
Annotation Type Update
@Target(value=METHOD) @Retention(value=RUNTIME) public @interface UpdateUsed in an interface to indicate to the pureQuery Generator that the annotated declared method runs an SQL INSERT, UPDATE, MERGE, DELETE, or DDL statement. The SQL statement can be specified in the
@Update
annotation,
and it must not return any ResultSet
s. See the pureQuery Runtime documentation for
details about how to specify SQL statements for annotated methods. When the pureQuery Generator is invoked for an
interface, it generates an implementation class for the interface. The generated version of a method that is
annotated with @Update
runs the specified SQL statement. Optional Element Summary
Modifier and Type | Optional Element and Description |
---|---|
pattern
For future enhancement.
|
|
positionedCursorName
Indicates that the SQL statement is a positioned UPDATE or DELETE statement for an updatable cursor, and provides
the name of that cursor.
|
|
sql
Indicates the SQL INSERT, UPDATE, MERGE, DELETE, or DDL statement to run when the implemented version of the annotated
method is invoked.
|
|
value
Indicates the SQL INSERT, UPDATE, MERGE, DELETE, or DDL statement to run when the implemented version of the annotated
method is invoked.
|
Optional Element Detail
pattern
public abstract String pattern
positionedCursorName
public abstract String positionedCursorName
Annotated methods can run positioned UPDATE and DELETE statements for updatable cursors. This is done by declaring
in a single interface a method that defines an updatable cursor and one or more annotated methods that define
positioned UPDATE or DELETE statements for that cursor. The annotated method that defines the cursor must have the
@Select
annotation and the @Cursor
annotation. The annotated methods that define the positioned UPDATE and DELETE statements must have
the @Update
annotation. The value of the @Cursor(cursorName=...)
attribute on the method that defines the cursor must be the same as the values of the
@Update(positionedCursorName=...)
attributes on the methods that define the positioned UPDATE
and DELETE statements.
When the positionedCursorName
attribute is specified for an annotated method, the SQL statement must
be an SQL UPDATE statement or an SQL DELETE statement. The SQL statement must not contain a "WHERE
"
clause. pureQuery adds a "WHERE CURRENT OF
cursorName" clause to the SQL statement.
Whenever an annotated method has a positioned cursor name cursorName provided in the
@Update(positionedCursorName=...)
attribute, another annotated method must be declared with the
following characteristics:
- The method must be declared in the same interface as the method that has the positioned cursor name.
- The method must have the
@Select
annotation. - The method must have the
@Cursor
annotation with thecursor
attribute set to the cursorName. - The cursor that is defined by the method must be updatable.
- The return type of the method must be either
Iterator
orResultSet
.
Iterator
or ResultSet
query result.
This is an example of a declaration of an annotated method that defines an updatable cursor:
@Select(sql = "SELECT * FROM EMPLOYEE")
@Cursor(cursorName = "EMPLOYEECURSOR", concurrency = java.sql.ResultSet.CONCUR_UPDATABLE)
Iterator<EmployeeBean> selectAllEmployees ();
This is an example of a declaration of an annotated method that defines a positioned UPDATE statement for the
updatable cursor:
@Update(sql = "UPDATE EMPLOYEE SET workdept = ?1.departmentNumber", positionedCursorName = "EMPLOYEECURSOR")
int updateEmployeeDepartment (EmployeeBean employeeBean);
sql
public abstract String sql
value
public abstract String value
Note: value=
does not need to be explicitly provided. For example, the SQL statement can be
specified as: @Update("DELETE FROM DEPARTMENT")
.