sqlg2
Annotation Type PrepareKey


@Retention(value=SOURCE)
@Target(value=LOCAL_VARIABLE)
public @interface PrepareKey

Annotation for local variables marking PreparedStatement to be generated. SQL query is taken from preceding javadoc comments.

Example:

 String messageText = ...;
 /**
  * INSERT INTO LOG (MESSAGE) VALUES (:messageText)
  */
 @PrepareKey("id") PreparedStatement stmt = null;
 executeUpdate(stmt);
 int id = getGeneratedKeys()[0].intValue();
 
Preprocessor generates code required to prepare statement with given auto-generated columns and set its parameters.

Note that parameters referenced in query (as :paramName) should be accessible as variables in the current scope.

You can use string and query substitution in comments, see Query.


Optional Element Summary
 java.lang.String value
          Comma-separated list of column names which are auto-generated by the statement.
 

value

public abstract java.lang.String value
Comma-separated list of column names which are auto-generated by the statement. Leave default value to return all generated keys (but the order is unspecified, plus such feature may be not supported).

Note that upper/lower case may be significant (depends on DB).

Generated key values can be retrieved by GBase.getGeneratedKeys(java.sql.PreparedStatement) method, which returns array of generated key values - one value for each given column (order of columns is preserved if the value was specified).

Default:
""