Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
When implementing data access logic using MyBatis, the most important and time-consuming step is to define the mappings between the queries for various database operations and the corresponding domain objects. The mapping is closely related to what operations are required and their underlying queries. So, for the contact information service, let’s define the ContactService interface that we will implement first. Listing 11-5 shows the interface.
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);
}