Listing 11-5. The ContactService Interface
package com.apress.prospring3.ch11.service;
import java.util.List;
import com.apress.prospring3.ch11.domain.Contact;
public interface ContactService {
// Find all contacts - without details
public List<Contact> findAll();
// Find all contacts - with tels and hobbies
public List<Contact> findAllWithDetail();
// Find by ID - with tels and hobbies
public Contact findById(Long id);
// Create a new or save an existing contact
public Contact save(Contact contact);
// Delete a contact
public void delete(Contact contact);
// Find a contact by first name and last name
public List<Contact> findByFirstNameAndLastName(String firstName,
String lastName);
}
The interface should be self-explanatory. It consists of a few finder methods for retrieving summary
or detail contact information, within which some accept parameters as searching criteria, while other
methods include insert, update, and delete operations. Later we will implement the service in the class
ContactServiceImpl.
Mapper Interfaces and SQL Mapping Files
The mapper interfaces and the mapping files make up the heart of how MyBatis works. They work
together with the domain objects to perform mapping between query results to domain objects, and vice
versa. For mapping each domain object, three main files are involved. Table 11-2 describes the files and
shows an example of each.
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home