May 2015
Intermediate to advanced
234 pages
4h 18m
English
In this recipe, we will create a DAO method to save an object in the database; a row will be added to the corresponding database table, for example:

You need to have a model class, for example:
public class User {
private Long id;
private String firstName;
private Integer age;You need to have a matching database table, for example:
CREATE TABLE `user` ( `id` int(11) AUTO_INCREMENT, `first_name` text, `age` int(11), PRIMARY KEY (`id`) )
You need to have a DAO class with a JdbcTemplate attribute (Refer to the Creating a DAO class recipe)
Define an SQL insert query with question marks as placeholders for the actual ...
Read now
Unlock full access