Refactoring from SQL to ORM
Refactoring from an SQL to an ORM implementation is simpler than you might think. Most of the refactoring involves the removal of excess code in the form of an SQL. In this next section, we will refactor our SQL implementation to a JPA implementation.
For JPA to map our domain objects to our database, we need to perform some mapping on our domain objects.
Mapping domain objects using JPA
Take a look at the following steps to learn about mapping the domain objects:
- Let’s begin by mapping our
Event.java
file so that all the domain objects will use JPA, as follows://src/main/java/com/packtpub/springsecurity/domain/Event.java @Entity @Table(name = "events") public class Event implements Serializable{ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; @NotEmpty(message = "Summary is required") ...