Siavash fallahdoust (4) [Avatar] Offline
You can use NamedParameterJdbcTemplate instead of JdbcTemplate in chapter 3.
JdbcTemplate is error-prone. The NamedParameterJdbcTemplate is a convenience that allows you to use named parameters.
for example, saveTacoInfo method in Listing 3.9 can be written like this :

taco.setCreatedAt(new Date());
SqlParameterSource namedParameters = new BeanPropertySqlParameterSource(taco);
KeyHolder keyHolder = new GeneratedKeyHolder();
namedParameterJdbcTemplate.update( "insert into Taco (name, createdAt) values (:name, :createdAt)", namedParameters, keyHolder, new String[]{"id"});
return keyHolder.getKey().longValue();

570807 (2) [Avatar] Offline

thank you for this solution! This one works, in contrast to the one with the JdbcTemplate where the KeyHolder is always empty, after the insert into the database.