|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectbr.com.arsmachina.dao.hibernate.BaseHibernateDAO<T,K>
br.com.arsmachina.dao.hibernate.ReadableDAOImpl<T,K>
T - the entity class related to this DAO.K - the type of the field that represents the entity class' primary key.public abstract class ReadableDAOImpl<T,K extends Serializable>
ReadableDAO implementation using Hibernate. All methods use BaseHibernateDAO.getSession() to get
Session.
| Field Summary | |
|---|---|
static br.com.arsmachina.dao.SortCriterion[] |
EMPTY_SORTING_CRITERIA
A SortCriterion array with no elements. |
| Constructor Summary | |
|---|---|
ReadableDAOImpl(Class<T> clasz,
org.hibernate.SessionFactory sessionFactory)
Constructor that takes a Class and a SessionFactory. |
|
ReadableDAOImpl(org.hibernate.SessionFactory sessionFactory)
Constructor that takes a Class and a SessionFactory. |
|
| Method Summary | |
|---|---|
protected void |
addSortCriteria(org.hibernate.Criteria criteria)
Adds the default sort criteria to a Criteria instance. |
void |
addSortCriteria(org.hibernate.Criteria criteria,
br.com.arsmachina.dao.SortCriterion... sortCriteria)
Adds sortCriteria to a Criteria instance. |
int |
countAll()
|
org.hibernate.Criteria |
createCriteria()
Creates a Criteria for this entity class. |
org.hibernate.Criteria |
createCriteria(int firstIndex,
int maximumResults,
br.com.arsmachina.dao.SortCriterion... sortCriteria)
Creates a Criteria for this entity class with given sort criteria,
first result index and maximum number of results. |
org.hibernate.Criteria |
createCriteria(br.com.arsmachina.dao.SortCriterion... sortCriteria)
Creates a Criteria for this entity class with given sort criteria. |
org.hibernate.criterion.Example |
createExample(T entity)
Used by findByExample(Object) to create an Example instance. |
List<T> |
findAll()
Returns all the entity class' objects. |
List<T> |
findAll(int firstResult,
int maximumResults,
br.com.arsmachina.dao.SortCriterion... sortingConstraints)
If sortingConstraints is null or empty, this implementation
sort the results by the SortCriterions returned by
#getDefaultSortCriterions(). |
List<T> |
findByExample(T example)
|
T |
findById(K id)
|
List<T> |
findByIds(K... ids)
|
String |
getDefaultHqlOrderBy()
Returns the value of the defaultHqlOrderBy property. |
br.com.arsmachina.dao.SortCriterion[] |
getDefaultSortCriteria()
Returns the default SortCriterions to be used to sort the objects lists returned by
methods like findAll() and findAll(int, int, SortCriterion...) when no
sorting constraints are given. |
T |
reattach(T object)
Reattaches the object to the current Session using
Session.lock(object, LockMode.NONE) and then returns the object. |
void |
refresh(T object)
|
static String |
toHqlOrderBy(br.com.arsmachina.dao.SortCriterion... sortCriteria)
Returns a HQL order by clause given some SortCriterions. |
| Methods inherited from class br.com.arsmachina.dao.hibernate.BaseHibernateDAO |
|---|
getClassMetadata, getEntityClass, getPrimaryKeyPropertyName, getSession, getSessionFactory |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final br.com.arsmachina.dao.SortCriterion[] EMPTY_SORTING_CRITERIA
SortCriterion array with no elements.
| Constructor Detail |
|---|
public ReadableDAOImpl(org.hibernate.SessionFactory sessionFactory)
Class and a SessionFactory.
clasz - a Class.sessionFactory - a SessionFactory. It cannot be null.
public ReadableDAOImpl(Class<T> clasz,
org.hibernate.SessionFactory sessionFactory)
Class and a SessionFactory.
clasz - a Class.sessionFactory - a SessionFactory. It cannot be null.| Method Detail |
|---|
public static final String toHqlOrderBy(br.com.arsmachina.dao.SortCriterion... sortCriteria)
order by clause given some SortCriterions.
sortCriteria - SortCriterion instances.
String.public int countAll()
countAll in interface br.com.arsmachina.dao.ReadableDAO<T,K extends Serializable>ReadableDAO.countAll()public List<T> findAll()
#getDefaultSortCriterions().
findAll in interface br.com.arsmachina.dao.ReadableDAO<T,K extends Serializable>ReadableDAO.findAll(),
#getDefaultSortCriterions()public T findById(K id)
findById in interface br.com.arsmachina.dao.ReadableDAO<T,K extends Serializable>ReadableDAO.findById(java.io.Serializable)public List<T> findByIds(K... ids)
findByIds in interface br.com.arsmachina.dao.ReadableDAO<T,K extends Serializable>br.com.arsmachina.dao.ReadableDAO#findByIds(K[])public List<T> findByExample(T example)
findByExample in interface br.com.arsmachina.dao.ReadableDAO<T,K extends Serializable>ReadableDAO.findByExample(java.lang.Object)public void refresh(T object)
refresh in interface br.com.arsmachina.dao.ReadableDAO<T,K extends Serializable>br.com.arsmachina.dao.WriteableDAO#refresh(java.lang.Object)
public List<T> findAll(int firstResult,
int maximumResults,
br.com.arsmachina.dao.SortCriterion... sortingConstraints)
sortingConstraints is null or empty, this implementation
sort the results by the SortCriterions returned by
#getDefaultSortCriterions().
findAll in interface br.com.arsmachina.dao.ReadableDAO<T,K extends Serializable>ReadableDAO.findAll(int, int,
br.com.arsmachina.dao.SortCriterion[])public T reattach(T object)
Session using
Session.lock(object, LockMode.NONE) and then returns the object.
reattach in interface br.com.arsmachina.dao.ReadableDAO<T,K extends Serializable>a - T.
object.ReadableDAO.reattach(java.lang.Object)
public final void addSortCriteria(org.hibernate.Criteria criteria,
br.com.arsmachina.dao.SortCriterion... sortCriteria)
sortCriteria to a Criteria instance.
criteria - a Criteria. It cannot be null.sortCriteria - a SortCriterion.... It cannot be null.protected void addSortCriteria(org.hibernate.Criteria criteria)
Criteria instance. This method just does
addSortCriteria(criteria, getDefaultSortCriteria());.
criteria - a Criteria. It cannot be null.public br.com.arsmachina.dao.SortCriterion[] getDefaultSortCriteria()
SortCriterions to be used to sort the objects lists returned by
methods like findAll() and findAll(int, int, SortCriterion...) when no
sorting constraints are given. This implementation returns EMPTY_SORTING_CRITERIA.
getDefaultSortCriteria in interface br.com.arsmachina.dao.ReadableDAO<T,K extends Serializable>SortCriterion array. It cannot be null.public org.hibernate.Criteria createCriteria()
Criteria for this entity class.
Criteria.public org.hibernate.Criteria createCriteria(br.com.arsmachina.dao.SortCriterion... sortCriteria)
Criteria for this entity class with given sort criteria.
Criteria.
public org.hibernate.Criteria createCriteria(int firstIndex,
int maximumResults,
br.com.arsmachina.dao.SortCriterion... sortCriteria)
Criteria for this entity class with given sort criteria,
first result index and maximum number of results.
Criteria.public org.hibernate.criterion.Example createExample(T entity)
findByExample(Object) to create an Example instance.
Example.public final String getDefaultHqlOrderBy()
defaultHqlOrderBy property.
String.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||