it.amattioli.dominate.hibernate
Class ClassHibernateRepository<I extends Serializable,T extends Entity<I>>

Show UML class diagram
java.lang.Object
  extended by it.amattioli.dominate.hibernate.AbstractHibernateRepository<I,T>
      extended by it.amattioli.dominate.hibernate.ClassHibernateRepository<I,T>
Type Parameters:
T - The class of the objects that can be accessed using this repository
I - The class of the identifier of the objects that can be accessed using this repository
All Implemented Interfaces:
Repository<I,T>, Cloneable

public class ClassHibernateRepository<I extends Serializable,T extends Entity<I>>
extends AbstractHibernateRepository<I,T>

A repository to access all the entities of a certain class persisted with Hibernate.

Author:
a.mattioli

Constructor Summary
ClassHibernateRepository(Class<T> repositoryClass)
          Create a repository for the entities whose class is passed as parameter
 
Method Summary
protected  void addOrder(org.hibernate.Criteria crit)
           
protected  String addOrder(String hqlQuery)
           
protected  org.hibernate.Criteria defaultCriteria()
           
 void fillCollection(Collection<? super T>... toBeFilled)
           
 void fillCollection(Filter criteria, Collection<? super T>... toBeFilled)
          Deprecated. 
 T get(I id)
          Retrieve an entity from this repository using its id.
<J extends Serializable,E extends Entity<J>>
Repository<J,E>
getDetailRepository(Collection<E> details)
           
 Filter getLastCriteria()
          Deprecated. 
 Class<T> getRepositoryClass()
          Retrieves the class of the entities that can be accessed using this repository
protected  void inMemoryOrder(List<T> result)
           
 boolean isCacheable()
           
 boolean isDbOrder()
           
 boolean isRemoveAllowed()
          Check if this repository supports object removal.
 List<T> list()
          Retrieves all the objects contained in this repository.
 List<T> list(Filter criteria)
          Deprecated. 
 List<T> list(Specification<T> spec)
          Retrieves the objects contained in this repository that satisfied the given specification.
 void put(T object)
          Add a new entity to this repository.
 void refresh(I objectId)
          If this repository is associated to an external data source (i.e a relational database) this method delete an object from the repository local cache so that a Repository.get(Serializable) will retrieve a fresh one from the data source.
 void refresh(T object)
          If this repository is associated to an external data source (i.e a relational database) this method delete an object from the repository local cache so that a Repository.get(Serializable) will retrieve a fresh one from the data source.
 void remove(I objectId)
          Removes an object from this repository.
 void remove(T object)
          Removes an object from this repository.
 void setCacheable(boolean cacheable)
           
 void setDbOrder(boolean dbOrder)
           
 String toString()
           
 
Methods inherited from class it.amattioli.dominate.hibernate.AbstractHibernateRepository
addOrder, clone, getByPropertyValue, getFirst, getHibernateSession, getHqlOrder, getLast, getOrderProperty, getOrders, getSessionManager, isReverseOrder, removeLastOrder, setFirst, setLast, setOrder, setSessionManager
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClassHibernateRepository

public ClassHibernateRepository(Class<T> repositoryClass)
Create a repository for the entities whose class is passed as parameter

Parameters:
repositoryClass - the class of the entities that can be accessed using this repository
Method Detail

getRepositoryClass

public Class<T> getRepositoryClass()
Retrieves the class of the entities that can be accessed using this repository

Returns:
the class of the entities that can be accessed using this repository

get

public T get(I id)
Description copied from interface: Repository
Retrieve an entity from this repository using its id.

Parameters:
id - the id of the entity you want to retrieve.
Returns:
the entity, contained in this repository, whose id is the same as the parameter

put

public void put(T object)
Description copied from interface: Repository
Add a new entity to this repository.

Parameters:
object - the entity you want to add

refresh

public void refresh(I objectId)
Description copied from interface: Repository
If this repository is associated to an external data source (i.e a relational database) this method delete an object from the repository local cache so that a Repository.get(Serializable) will retrieve a fresh one from the data source. If the repository is not associated to an external data source or it has no local cache this method will have no effect.

Parameters:
objectId - the id of the object to be refreshed

refresh

public void refresh(T object)
Description copied from interface: Repository
If this repository is associated to an external data source (i.e a relational database) this method delete an object from the repository local cache so that a Repository.get(Serializable) will retrieve a fresh one from the data source. If the repository is not associated to an external data source or it has no local cache this method will have no effect.

Parameters:
object - the object to be refreshed

isRemoveAllowed

public boolean isRemoveAllowed()
Description copied from interface: Repository
Check if this repository supports object removal.

Returns:
true if this repository supports object removal

remove

public void remove(I objectId)
Description copied from interface: Repository
Removes an object from this repository. Before calling this method clients should check id this repository supports object removal using Repository.isRemoveAllowed()

Parameters:
objectId - the id of the object to remove

remove

public void remove(T object)
Description copied from interface: Repository
Removes an object from this repository. Before calling this method clients should check id this repository supports object removal using Repository.isRemoveAllowed()

Parameters:
object - the object to remove

defaultCriteria

protected org.hibernate.Criteria defaultCriteria()

isDbOrder

public boolean isDbOrder()

setDbOrder

public void setDbOrder(boolean dbOrder)

addOrder

protected String addOrder(String hqlQuery)

addOrder

protected void addOrder(org.hibernate.Criteria crit)

inMemoryOrder

protected void inMemoryOrder(List<T> result)

list

public List<T> list()
Description copied from interface: Repository
Retrieves all the objects contained in this repository. The order of the object inside the list depends on the "order" property. If "first" and "last" properties have been set only a part of the entities will be retrieved.

Returns:
all the entities contained in this repository
See Also:
#setFirst(int)}, {@link #setLast(int)}, {@link #setOrder(String, boolean)}

list

@Deprecated
public List<T> list(Filter criteria)
Deprecated. 

Description copied from interface: Repository
Retrieves the objects contained in this repository that match the specified filter. The order of the object inside the list depends on the "order" property. If "first" and "last" properties have been set only a part of the entities will be retrieved.

Parameters:
criteria - the filter to be used
Returns:
the objects contained in this repository that match the specified filter
See Also:
#setFirst(int)}, {@link #setLast(int)}, {@link #setOrder(String, boolean)}

list

public List<T> list(Specification<T> spec)
Description copied from interface: Repository
Retrieves the objects contained in this repository that satisfied the given specification. The order of the object inside the list depends on the "order" property. If "first" and "last" properties have been set only a part of the entities will be retrieved.

Parameters:
spec - the specification that must be satisfied
Returns:
the objects contained in this repository that satisfied the given specification

getLastCriteria

@Deprecated
public Filter getLastCriteria()
Deprecated. 


getDetailRepository

public <J extends Serializable,E extends Entity<J>> Repository<J,E> getDetailRepository(Collection<E> details)

isCacheable

public boolean isCacheable()

setCacheable

public void setCacheable(boolean cacheable)

fillCollection

@Deprecated
public void fillCollection(Filter criteria,
                                      Collection<? super T>... toBeFilled)
Deprecated. 


fillCollection

public void fillCollection(Collection<? super T>... toBeFilled)

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011. All Rights Reserved.