forked from DevFW-CICD/spring-petclinic
started adding support for Spring Data
This commit is contained in:
parent
df5c5ca59d
commit
5432a1932c
11 changed files with 93 additions and 29 deletions
|
|
@ -43,7 +43,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
* {@link ParameterizedBeanPropertyRowMapper} which provide automatic mapping
|
||||
* between JavaBean properties and JDBC parameters or query results.
|
||||
*
|
||||
* <p>JdbcClinic is a rewrite of the AbstractJdbcClinic which was the base
|
||||
* <p>JdbcClinicImpl is a rewrite of the AbstractJdbcClinic which was the base
|
||||
* class for JDBC implementations of the Clinic interface for Spring 2.0.
|
||||
*
|
||||
* @author Ken Krebs
|
||||
|
|
@ -55,7 +55,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
*/
|
||||
@Service
|
||||
@ManagedResource("petclinic:type=Clinic")
|
||||
public class JdbcClinic implements Clinic, JdbcClinicMBean {
|
||||
public class JdbcClinicImpl implements Clinic, JdbcClinicImplMBean {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
|
|
@ -6,14 +6,14 @@ package org.springframework.samples.petclinic.jdbc;
|
|||
*
|
||||
* @author Rob Harrop
|
||||
* @author Juergen Hoeller
|
||||
* @see JdbcClinic
|
||||
* @see JdbcClinicImpl
|
||||
*/
|
||||
public interface JdbcClinicMBean {
|
||||
public interface JdbcClinicImplMBean {
|
||||
|
||||
/**
|
||||
* Refresh the cache of Vets that the Clinic is holding.
|
||||
* @see org.springframework.samples.petclinic.Clinic#getVets()
|
||||
* @see JdbcClinic#refreshVetsCache()
|
||||
* @see JdbcClinicImpl#refreshVetsCache()
|
||||
*/
|
||||
void refreshVetsCache();
|
||||
|
||||
|
|
@ -7,7 +7,7 @@ import org.springframework.samples.petclinic.Pet;
|
|||
* are only relevant for a JDBC implmentation of the Clinic.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @see JdbcClinic
|
||||
* @see JdbcClinicImpl
|
||||
*/
|
||||
class JdbcPet extends Pet {
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import org.springframework.dao.DataAccessException;
|
|||
*/
|
||||
@Repository
|
||||
@Transactional
|
||||
public class JpaClinic implements Clinic {
|
||||
public class JpaClinicImpl implements Clinic {
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager em;
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
package org.springframework.samples.petclinic.jpa;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.samples.petclinic.Clinic;
|
||||
import org.springframework.samples.petclinic.Owner;
|
||||
import org.springframework.samples.petclinic.Pet;
|
||||
import org.springframework.samples.petclinic.PetType;
|
||||
import org.springframework.samples.petclinic.Vet;
|
||||
import org.springframework.samples.petclinic.Visit;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Michael Isvy
|
||||
* @since 15.1.2013
|
||||
*/
|
||||
public interface SpringDataClinic extends Clinic, Repository {
|
||||
|
||||
|
||||
|
||||
@Query("SELECT vet FROM Vet vet ORDER BY vet.lastName, vet.firstName")
|
||||
public Collection<Vet> getVets();
|
||||
|
||||
@Query("SELECT ptype FROM PetType ptype ORDER BY ptype.name")
|
||||
public Collection<PetType> getPetTypes();
|
||||
|
||||
@Query("SELECT owner FROM Owner owner WHERE owner.lastName LIKE :lastName")
|
||||
public Collection<Owner> findOwners(String lastName);
|
||||
|
||||
|
||||
public Owner findOwner(int id);
|
||||
|
||||
public Pet findPet(int id);
|
||||
|
||||
public void storeOwner(Owner owner);
|
||||
|
||||
public void storePet(Pet pet);
|
||||
|
||||
public void storeVisit(Visit visit);
|
||||
|
||||
public void deletePet(int id);
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue