Make @SqlUpdate able to return the generated keys
See original GitHub issueAs I checked, the Update
does have a method executeAndReturnGeneratedKeys
to return the insert statement’s generated keys. But when I use the SqlObject api @SqlUpdate
, it only returns the updated rows count. What about to add a property in @SqlUpdate
to tell the UpdateHandler to return the generated keys?
Issue Analytics
- State:
- Created 11 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Returning the Generated Keys in JDBC - Baeldung
Learn how to return auto-generated keys with only the JDBC. ... In order to be able to execute SQL queries, we're going to...
Read more >BatchSqlUpdate - how to get auto generated keys
How do I get the auto generated keys for all of the rows inserted? When doing a single insert I get the keys...
Read more >Retrieving auto-generated keys for an INSERT statement - IBM
Use one of the following methods to indicate that you want to return automatically generated keys: If you plan to use the PreparedStatement.executeUpdate...
Read more >Batch inserts with auto incremented keys - Google Groups
JDBI says that batch methods must either return void or int[] array with the ... Yes, I know I can do single insert...
Read more >Documentation: 15: UPDATE - PostgreSQL
The optional RETURNING clause causes UPDATE to compute and return value(s) ... Do not include the table's name in the specification of a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
At least in Postgres, you can e.g.
INSERT ... RETURNING *
and then use@SqlQuery
instead and it should work. Not sure about other databases.From the little research I’ve done online, you can just annotate the method like this. @SqlUpdate(“insert into user(username) values (‘douglas’)”) @GetGeneratedKeys public long createUser();
and then get the long returned from the DAO