spring-in-action-5-samples: Chapter 3 JDBC problems

  1. In chapter 3 there isn’t a mention about adding “IngredientByIdConverter” - without it the app crashes after saving taco design.

  2. The code in JdbcTacoRepository.saveTacoInfo() often results in NullPointerException. The solution is to set flag “setReturnGeneratedKeys(true)” on PreparedStatementCreatorFactory object:

PreparedStatementCreatorFactory pscf = new PreparedStatementCreatorFactory(QUERY_SAVE_TACO, Types.VARCHAR, Types.TIMESTAMP);
pscf.setReturnGeneratedKeys(true);
PreparedStatementCreator psc = pscf.newPreparedStatementCreator(Arrays.asList(taco.getName(), new Timestamp(taco.getCreatedAt().getTime())));

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 26
  • Comments: 15 (1 by maintainers)

Most upvoted comments

Can someone explain to me why we have created the class Integrientbyidconverter, but do not use its method anywhere?