This page indicates that the project was created normally, and we can now proceed to implement
the service layer and expose it for remote access.
Data Model for Samples
For the data model in the samples in this chapter, we will use a very simple one, which contains only a
single CONTACT table for storing contact information. Listing 16-1 shows the script for schema creation
(schema.sql in the /src/main/resources folder).
Listing 16-1. Sample Database Schema
DROP TABLE IF EXISTS CONTACT;
CREATE TABLE CONTACT (
ID INT NOT NULL AUTO_INCREMENT
, FIRST_NAME VARCHAR(60) NOT NULL
, LAST_NAME VARCHAR(40) NOT NULL
, BIRTH_DATE DATE
, VERSION INT NOT NULL DEFAULT 0
, UNIQUE UQ_CONTACT_1 (FIRST_NAME, LAST_NAME)
, PRIMARY KEY (ID)
);
As you can see, the CONTACT table stores only a few basic fields of a contact's information. Listing 16-
2 shows the testing data population script (test-data.sql).
Listing 16-2. Sample Data Population Script
insert into contact (first_name, last_name, birth_date) values
('Clarence', 'Ho', '1980-07-30');
insert into contact (first_name, last_name, birth_date) values
('Scott', 'Tiger', '1990-11-02');
insert into contact (first_name, last_name, birth_date) values
('John', 'Smith', '1964-02-28');
Implementing and Configuring ContactService
Having the template 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 discuss the implementation of the ContactService using JPA 2,
Spring Data JPA, and Hibernate as the persistence service provider. Then, we will cover how to configure
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 remote
clients. First we need to create the Contact entity class, which is shown in Listing 16-3.
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home