In this recipe, you will learn how to use Hibernate with Spring. We'll use a MySQL database.
In this recipe, we'll use a MySQL database with the user
table:
CREATE TABLE user ( id int NOT NULL AUTO_INCREMENT, first_name text, age int DEFAULT NULL, PRIMARY KEY (id) );
We'll use this corresponding JPA-annotated domain class:
@Entity @Table(name = "user") public class User { @Id @GeneratedValue private Long id; @Column(name = "first_name") private String firstName; private Integer age; // getters and setters..
For more information about the Java Persistence API (JPA), go to: http://docs.oracle.com/javaee/6/tutorial/doc/bnbpz.html.