| public interface class java.sql AutoGeneratedKeys
|
Java SE 6 |
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.
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 interface MyQueries{@Update(sql="insert into tabName(?1, ?2)", keys=GeneratedKeys.RETURNED_KEYS_DRIVER_DEFINED) 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.
| since | 1.6 |
| See also | java.sql.GeneratedKeys, executeUpdate(java.lang.String, java.lang.String []), executeUpdate(java.lang.String, int) |
| About DocWeb · Bundles · Export · Export All | Top 10 · Statistics · Login |
| About Sun · Contact · Privacy · Terms of Use · Trademarks | Java SE 6 · Copyright © 1994-2009 Sun Microsystems, Inc.All rights reserved. Use is subject to license terms |
![]() |
![]() |
|