Indicating that the values in a column that maps to a bean property are auto-generated

The @GeneratedKey annotation indicates that an SQL column is an auto-generated column. That is, the value is automatically assigned by the database during INSERT or UPDATE operations.

If a bean that contains this annotation is provided as the only parameter for an INSERT or UPDATE operation with an annotated method, or the Data interface method defined int update(String sql, Object... parameters), then annotated properties are updated before control is returned to your application.

Attention: If you pass two or more beans as input parameters to an update operation, and at least one @GeneratedKey annotation exists in each bean, the update operation does not succeed. This restriction applies to the update() method (for the inline programming style) and to methods in @Update annotations (for the annotated-method programming style).

Feedback