This provides GenericDAOImpl, an abstract
class that implements all DAO
(from the
Generic DAO
package) methods using
Hibernate. Subclassing it,
all your DAO implementations must do is to implement the specific
database queries, not the common ones.
GenericDAOImpl methodsThis class has some useful methods:
static String toHqlOrderBy(SortCriterion... sortCriteria)
Creates an HQL ORDER BY clause equivalent to an
array of SortCriterion instances.
static void addSortCriteria(Criteria criteria, SortCriterion... sortCriteria)
Adds an array of SortCriterions to a Criteria
query.
SortCriterion[] getDefaultSortCriteria()
(defined in ReadableDAO
Defines the default sort criteria (the one used when no sort criteria is given).
For example, the sorting criteria used by the findAll
method is exactly the one defined by this method. Its implementation
in GenericDAOImpl returns an empty array (no sort criteria
is applied).
SessionFactory getSessionFactory()
returns the org.hibernate.SessionFactory being used.
Session getSession()
returns an org.hibernate.Session. This method must be
used by all methods that need a Session. It returns
getSessionFactory().getCurrentSession().