
Spring provides GeneratedKeyHolder (Java Doc) class which can be used to retrieve the auto generated values.
Most of the examples will not contain the whole code and may omit fragments which are not relevant to the example being discussed. The readers can download or view all code from the above link.
Spring JDBC Template Batch Update Example Spring provides Batch operations with the help of JdbcTemplate, It insert or update records into database into one shot. The Spring Named Parameter JDBC template expects an SQL statement with parameter markers in the Spring format, and a set of matched parameters. MyBatis Dynamic SQL will generate both. The parameters returned from the generated SQL statement can be wrapped in a Spring MapSqlParameterSource. Spring also expects you to provide a row mapper for. Dismiss All your code in one place. GitHub makes it easy to scale back on context switching. Read rendered documentation, see the history of any file, and collaborate with contributors on projects across GitHub. Cache key generator. Used for creating a key based on the given method (used as context) and its parameters.

The following class shows how to retrieve the auto generated key after a new value is added to the table.
The readers can download or view the code from https://github.com/javacreed/how-to-get-auto-generated-key-with-jdbctemplate/.