com.ibm.pdq.annotation
Annotation Type Update


@Target(value=METHOD)
@Retention(value=RUNTIME)
public @interface Update

Used in an interface to indicate to the pureQuery Generator that the annotated declared method runs an SQL INSERT, UPDATE, DELETE, or DDL statement. The SQL statement can be specified in the @Update annotation, and it must not return any ResultSets. See the IBM Optim 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
 String pattern
          For future enhancement.
 String positionedCursorName
          Indicates that the SQL statement is a positioned UPDATE or DELETE statement for an updatable cursor, and provides the name of that cursor.
 String sql
          Indicates the SQL INSERT, UPDATE, DELETE, or DDL statement to run when the implemented version of the annotated method is invoked.
 String value
          Indicates the SQL INSERT, UPDATE, DELETE, or DDL statement to run when the implemented version of the annotated method is invoked.

 

pattern

public abstract String pattern
For future enhancement.
Default:
""

positionedCursorName

public abstract String positionedCursorName
Indicates that the SQL statement is a positioned UPDATE or DELETE statement for an updatable cursor, and provides the name of that cursor.

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:

When the positioned UPDATE or DELETE method is run, it updates or deletes the row that was most recently retrieved from the 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);

Default:
""

sql

public abstract String sql
Indicates the SQL INSERT, UPDATE, DELETE, or DDL statement to run when the implemented version of the annotated method is invoked. For database queries, the SQL statement must be executable by the target database. For queries over collections, the syntax must conform to the SQL92 standard syntax, with pureQuery extensions.
Default:
""

value

public abstract String value
Indicates the SQL INSERT, UPDATE, DELETE, or DDL statement to run when the implemented version of the annotated method is invoked. For database queries, the SQL statement must be executable by the target database. For queries over collections, the syntax must conform to the SQL92 standard syntax, with pureQuery extensions.

Note: value= does not need to be explicitly provided. For example, the SQL statement can be specified as: @Update("DELETE FROM DEPARTMENT").

Default:
""