Reputation: 677
Following "Spring In Action 5" implemented the code using Spring 2.1.1 and Java 11 but ran into the issue that JdbcTemplage.update(PreparedStatementCreator, KeyHolder) does not update keyholder and I get null key when calling keyholder.getKey(). Code can be checked out from https://github.com/Kiarashz/mytacos/blob/0.0.2/src/main/java/tacos/data/JdbcTacoRepository.java#L48
Wondering what could be the cause of issue? Thanks
Upvotes: 0
Views: 909
Reputation: 677
While not required when using Spring Boot version 2.0.4, I had to call PreparedStatementCreatorFactory.setReturnGeneratedKeys(boolean value) setting value to true to make it work for the latest versions of Spring Boot (2.1.1) and H2 database (1.4.197).
Upvotes: 2