This time, more testing data was populated in order to show you the pagination support later.
Implementing and Configuring ContactService
Having the project created and sample data model and scripts ready, we can start to implement and
configure the service layer for our samples in this chapter.
In the following sections, we will first discuss the implementation of the ContactService using JPA 2,
Spring Data JPA, and Hibernate as the persistence service provider. Then we will cover the configuration
of the service layer in the Spring project.
Implementing ContactService
In the samples, we will expose the services for various operations on the contact information to the
presentation layer. First we need to create the Contact entity class, which is shown in Listing 17-3.
Listing 17-3. The Contact Entity Class
package com.apress.prospring3.ch17.domain;
import static javax.persistence.GenerationType.IDENTITY;
import java.io.Serializable;
import javax.persistence.*;
import
org.hibernate.annotations.Type;
import
org.joda.time.DateTime;
import
org.springframework.format.annotation.DateTimeFormat;
import
org.springframework.format.annotation.DateTimeFormat.ISO;
@Entity
@Table(name = "contact")
public class Contact implements Serializable {
private
Long id;
private
int version;
private
String firstName;
private
String lastName;
private
DateTime birthDate;
private
String description;
private
byte[] photo;
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "ID")
public Long getId() {
return id;
}
@Version
@Column(name = "VERSION")
public int getVersion() {
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home