import org.springframework.data.domain.Pageable;
import com.apress.prospring3.springblog.domain.Entry;
import com.apress.prospring3.springblog.domain.SearchCriteria;
public interface EntryService {
public List<Entry> findAll();
public Entry findById(Long id);
public List<Entry> findByCategoryId(String categoryId);
public Entry save(Entry entry);
public void delete(Entry entry);
public Page<Entry> findAllByPage(Pageable pageable);
public Page<Entry> findEntryByCriteria(SearchCriteria searchCriteria, Pageable pageable);
}
In Listing 21-10, various finder methods, some with pagination support, and the data update
(including insert, update, and delete operations) are defined. To keep the discussion simple, we will
focus on the implementation of the save() method, which is highlighted in bold.
For the details about the design and implementation of the DOM for blog post entry, see Chapter 12.
If you haven't read the chapter, it's time to take a look at it to understand the design of the domain
object model.
JPA Service Implementation
For the JPA 2 implementation of the service layer, Hibernate will be used as the persistence provider. In
addition, Spring Data JPA's repository abstraction will be used to simplify the development of
persistence logic. As mentioned in the section "The Spring WebApplicationContext Hierarchy," the
configuration for the JPA implementation is provided in the files jpa-tx-config.xml and jpa-service-
context.xml files. For a detailed explanation of the configuration, please refer to Chapter 10.
Spring Data JPA's repository abstraction will be used for persistence logic, so we need to implement
the repository interface for the Entry object. Listing 21-11 shows the EntryRepository interface.
Listing 21-11. The EntryRepository Interface
package com.apress.prospring3.springblog.repository;
import java.util.List;
import
org.joda.time.DateTime;
import
org.springframework.data.domain.Page;
import
org.springframework.data.domain.Pageable;
import
org.springframework.data.jpa.repository.Query;
import
org.springframework.data.repository.PagingAndSortingRepository;
import
org.springframework.data.repository.query.Param;
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home