org.springframework.samples.petclinic.hibernate
Class HibernateClinic

java.lang.Object
  extended by org.springframework.samples.petclinic.hibernate.HibernateClinic
All Implemented Interfaces:
Clinic

@Repository
@Transactional
public class HibernateClinic
extends java.lang.Object
implements Clinic

Hibernate implementation of the Clinic interface.

The mappings are defined in "petclinic.hbm.xml", located in the root of the class path.

Note that transactions are declared with annotations and that some methods contain "readOnly = true" which is an optimization that is particularly valuable when using Hibernate (to suppress unnecessary flush attempts for read-only operations).

Since:
19.10.2003
Author:
Juergen Hoeller, Sam Brannen, Mark Fisher

Constructor Summary
HibernateClinic(org.hibernate.SessionFactory sessionFactory)
           
 
Method Summary
 void deletePet(int id)
          Deletes a Pet from the data store.
 java.util.Collection<Owner> findOwners(java.lang.String lastName)
          Retrieve Owners from the data store by last name, returning all owners whose last name starts with the given name.
 java.util.Collection<PetType> getPetTypes()
          Retrieve all PetTypes from the data store.
 java.util.Collection<Vet> getVets()
          Retrieve all Vets from the data store.
 Owner loadOwner(int id)
          Retrieve an Owner from the data store by id.
 Pet loadPet(int id)
          Retrieve a Pet from the data store by id.
 void storeOwner(Owner owner)
          Save an Owner to the data store, either inserting or updating it.
 void storePet(Pet pet)
          Save a Pet to the data store, either inserting or updating it.
 void storeVisit(Visit visit)
          Save a Visit to the data store, either inserting or updating it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HibernateClinic

public HibernateClinic(org.hibernate.SessionFactory sessionFactory)
Method Detail

getVets

@Transactional(readOnly=true)
public java.util.Collection<Vet> getVets()
Description copied from interface: Clinic
Retrieve all Vets from the data store.

Specified by:
getVets in interface Clinic
Returns:
a Collection of Vets

getPetTypes

@Transactional(readOnly=true)
public java.util.Collection<PetType> getPetTypes()
Description copied from interface: Clinic
Retrieve all PetTypes from the data store.

Specified by:
getPetTypes in interface Clinic
Returns:
a Collection of PetTypes

findOwners

@Transactional(readOnly=true)
public java.util.Collection<Owner> findOwners(java.lang.String lastName)
Description copied from interface: Clinic
Retrieve Owners from the data store by last name, returning all owners whose last name starts with the given name.

Specified by:
findOwners in interface Clinic
Parameters:
lastName - Value to search for
Returns:
a Collection of matching Owners (or an empty Collection if none found)

loadOwner

@Transactional(readOnly=true)
public Owner loadOwner(int id)
Description copied from interface: Clinic
Retrieve an Owner from the data store by id.

Specified by:
loadOwner in interface Clinic
Parameters:
id - the id to search for
Returns:
the Owner if found

loadPet

@Transactional(readOnly=true)
public Pet loadPet(int id)
Description copied from interface: Clinic
Retrieve a Pet from the data store by id.

Specified by:
loadPet in interface Clinic
Parameters:
id - the id to search for
Returns:
the Pet if found

storeOwner

public void storeOwner(Owner owner)
Description copied from interface: Clinic
Save an Owner to the data store, either inserting or updating it.

Specified by:
storeOwner in interface Clinic
Parameters:
owner - the Owner to save
See Also:
BaseEntity.isNew()

storePet

public void storePet(Pet pet)
Description copied from interface: Clinic
Save a Pet to the data store, either inserting or updating it.

Specified by:
storePet in interface Clinic
Parameters:
pet - the Pet to save
See Also:
BaseEntity.isNew()

storeVisit

public void storeVisit(Visit visit)
Description copied from interface: Clinic
Save a Visit to the data store, either inserting or updating it.

Specified by:
storeVisit in interface Clinic
Parameters:
visit - the Visit to save
See Also:
BaseEntity.isNew()

deletePet

public void deletePet(int id)
               throws org.springframework.dao.DataAccessException
Description copied from interface: Clinic
Deletes a Pet from the data store.

Specified by:
deletePet in interface Clinic
Throws:
org.springframework.dao.DataAccessException


Copyright © 2010. All Rights Reserved.