@Documented @Retention(value=RUNTIME) @Target(value=TYPE) public @interface AutoGeneratedKeys
Annotation used to indicate that a DataSet returned by invoking a method decorated by the Update annotation is used to hold the columns which represent the returned. auto-generated keys. To return auto-generated keys, the keys annotation element will have a value of GeneratedKeys.RETURNED_KEYS_DRIVER_DEFINED or GeneratedKeys.RETURNED_KEYS_COLUMNS_SPECIFIED.
Annotation used to indicate that the fields contained in a DataSet represent the columns to be returned as auto-generated keys. This annotation provides functionality similar to
Statement.executeUpdate(java.lang.String, java.lang.String [])
which allows a developer to define the columns to be returned as the auto-generated keys.
A data class that wishes to store auto-generated keys in a DataSet needs to annotate the data class with this marker annotation.
For example:
@AutoGeneratedKeys public class myKeys { public String col1;public String col2;} public interface MyQueries{ @Update(sql="insert into tabName(?1, ?2)", keys=GeneratedKeys.RETURNED_KEYS_DRIVER_DEFINED)keys=GeneratedKeys.ALL_KEYS)DatSet<myKeys> addPerson(String name, int age); }
After a call to the annotated method, addPerson, the auto-generated keys if any are stored in the DataSet. The JDBC driver will determine which columns to return as the auto-generated key. If the data class , myKeys, is not annotated with the AutoGeneratedKeys annotation, then a SQLRuntimeException is thrown.