Using JPA for smart data persistence
The Java Persistence API is a specification that describes an interface for managing relational databases using Java EE.
It eases data manipulation and reduces a lot of the code written for it, especially if you are used to SQL ANSI.
This recipe will show you how to use it to persist your data.
Getting ready
Let's first add the dependencies needed:
<dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager</artifactId> <version>4.3.1.Final</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> <dependency> <groupId>org.hamcrest</groupId> <artifactId>hamcrest-core...