We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
spring-in-action-5-samples/ch03/tacos-jdbc/src/main/java/tacos/data/JdbcTacoRepository.java
Line 38 in ff98b2e
Following an answer to question on StackOverflow.
JdbcTacoRepository is missing a crucial peace: preparedStatementCreatorFactory.setReturnGeneratedKeys(true);
preparedStatementCreatorFactory.setReturnGeneratedKeys(true);
This is a working method:
private long saveTacoInfo(Taco taco) { taco.setCreatedAt(new Date()); var pscf = new PreparedStatementCreatorFactory( "insert into Taco (name, createdAt) values (?, ?)", Types.VARCHAR, Types.TIMESTAMP); pscf.setReturnGeneratedKeys(true); PreparedStatementCreator psc = pscf.newPreparedStatementCreator( Arrays.asList( taco.getName(), new Timestamp(taco.getCreatedAt().getTime()))); KeyHolder keyHolder = new GeneratedKeyHolder(); jdbc.update(psc, keyHolder); return keyHolder.getKey().longValue(); }
The text was updated successfully, but these errors were encountered:
<properties> <!-- H2 1.4.197 breaks auto-incrementing identity columns for some reason --> <h2.version>1.4.196</h2.version> </properties>
Sorry, something went wrong.
No branches or pull requests
spring-in-action-5-samples/ch03/tacos-jdbc/src/main/java/tacos/data/JdbcTacoRepository.java
Line 38 in ff98b2e
Following an answer to question on StackOverflow.
JdbcTacoRepository is missing a crucial peace:
preparedStatementCreatorFactory.setReturnGeneratedKeys(true);
This is a working method:
The text was updated successfully, but these errors were encountered: