nl.gridshore.samples.training.dataaccess.jpa
Class BaseDaoJpa<T extends nl.gridshore.samples.training.domain.BaseDomain>

java.lang.Object
  extended by nl.gridshore.samples.training.dataaccess.jpa.BaseDaoJpa<T>
All Implemented Interfaces:
BaseDao<T>
Direct Known Subclasses:
EmployeeDaoJpa, ProjectDaoJpa, TrainingDaoJpa

public class BaseDaoJpa<T extends nl.gridshore.samples.training.domain.BaseDomain>
extends java.lang.Object
implements BaseDao<T>

Created by IntelliJ IDEA. User: jettro Date: Jan 20, 2008 Time: 5:03:11 PM Standard implementation for the base interface data access objects


Constructor Summary
BaseDaoJpa(java.lang.Class<T> prototype, java.lang.String entityName)
           
 
Method Summary
 void delete(T entity)
          Removes the provided item from the persistent storage
 javax.persistence.EntityManager getEntityManager()
           
 java.util.List<T> loadAll()
          Returns list of all objects
 T loadById(java.lang.Long entityId)
          Load the object belonging to the specified type
protected  T newPrototype(java.lang.Class<T> cl)
           
 T save(T entity)
          Store an existing entity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseDaoJpa

public BaseDaoJpa(java.lang.Class<T> prototype,
                  java.lang.String entityName)
Method Detail

save

public T save(T entity)
Description copied from interface: BaseDao
Store an existing entity

Specified by:
save in interface BaseDao<T extends nl.gridshore.samples.training.domain.BaseDomain>
Parameters:
entity - Object to store
Returns:
Reference to the stored object.

loadById

public T loadById(java.lang.Long entityId)
                                                                   throws org.springframework.orm.ObjectRetrievalFailureException
Description copied from interface: BaseDao
Load the object belonging to the specified type

Specified by:
loadById in interface BaseDao<T extends nl.gridshore.samples.training.domain.BaseDomain>
Parameters:
entityId - Long representing the type of the object to load
Returns:
Object found belonging to the specified type
Throws:
org.springframework.orm.ObjectRetrievalFailureException - if the entity for id does not exist

loadAll

public java.util.List<T> loadAll()
Description copied from interface: BaseDao
Returns list of all objects

Specified by:
loadAll in interface BaseDao<T extends nl.gridshore.samples.training.domain.BaseDomain>
Returns:
List of all available objects

delete

public void delete(T entity)
Description copied from interface: BaseDao
Removes the provided item from the persistent storage

Specified by:
delete in interface BaseDao<T extends nl.gridshore.samples.training.domain.BaseDomain>
Parameters:
entity - Entity to remove from persistent storage

newPrototype

protected final T newPrototype(java.lang.Class<T> cl)
                                                                                throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

getEntityManager

public javax.persistence.EntityManager getEntityManager()


Copyright © 2008. All Rights Reserved.