@Documented @Retention(value=RUNTIME) @Target(value=TYPE) public @interface AutoGeneratedKeys
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.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
.
If the data class, myKeys, is not annotated with the AutoGeneratedKeys
annotation,
then a SQLRuntimeException
is thrown.