Package org.kiwiproject.hibernate
Class CriteriaQueries
- java.lang.Object
-
- org.kiwiproject.hibernate.CriteriaQueries
-
public class CriteriaQueries extends Object
Utility class for creating HibernateCriteriaqueries.- Implementation Note:
- Suppressing all IntelliJ and Sonar deprecation warnings. We are aware that the Hibernate Criteria API is deprecated.
-
-
Constructor Summary
Constructors Constructor Description CriteriaQueries()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.hibernate.CriteriaaddOrder(org.hibernate.Criteria criteria, String orderClause)Adds the specified order clause to an existingCriteria, returning the criteria that was passed in.static org.hibernate.CriteriadistinctCriteria(org.hibernate.Session session, Class<?> persistentClass)Creates aCriteriaquery for the specified persistent class.static org.hibernate.CriteriadistinctCriteria(org.hibernate.Session session, Class<?> persistentClass, String orderClause, String... fetchAssociations)Creates aCriteriaquery for the specified persistent class, with the specified ordering, and settingFetchMode.JOINon the specifiedfetchAssociations.static org.hibernate.CriteriadistinctCriteriaWithFetchAssociations(org.hibernate.Session session, Class<?> persistentClass, String... fetchAssociations)Creates aCriteriaquery for the specified persistent class and settingFetchMode.JOINon the specifiedfetchAssociations.static org.hibernate.CriteriadistinctCriteriaWithOrder(org.hibernate.Session session, Class<?> persistentClass, String orderClause)Creates aCriteriaquery for the specified persistent class and the specified HQL order clause.
-
-
-
Method Detail
-
distinctCriteria
public static org.hibernate.Criteria distinctCriteria(org.hibernate.Session session, Class<?> persistentClass, String orderClause, String... fetchAssociations)Creates aCriteriaquery for the specified persistent class, with the specified ordering, and settingFetchMode.JOINon the specifiedfetchAssociations.- Parameters:
session- the Hibernate sessionpersistentClass- the class for which to create a criteria queryorderClause- the order specificationfetchAssociations- one or more associations to fetch via a join- Returns:
- a
Criteriawhich you can build upon - See Also:
addOrder(Criteria, String),distinctCriteriaWithFetchAssociations(org.hibernate.Session, Class, String...)
-
distinctCriteriaWithOrder
public static org.hibernate.Criteria distinctCriteriaWithOrder(org.hibernate.Session session, Class<?> persistentClass, String orderClause)Creates aCriteriaquery for the specified persistent class and the specified HQL order clause.- Parameters:
session- the Hibernate sessionpersistentClass- the class for which to create a criteria queryorderClause- the order specification- Returns:
- a {code Criteria} which you can build upon
- See Also:
addOrder(Criteria, String)
-
distinctCriteriaWithFetchAssociations
public static org.hibernate.Criteria distinctCriteriaWithFetchAssociations(org.hibernate.Session session, Class<?> persistentClass, String... fetchAssociations)Creates aCriteriaquery for the specified persistent class and settingFetchMode.JOINon the specifiedfetchAssociations.- Parameters:
session- the Hibernate sessionpersistentClass- the class for which to create a criteria queryfetchAssociations- one or more associations to fetch via a join- Returns:
- a
Criteriawhich you can build upon
-
distinctCriteria
public static org.hibernate.Criteria distinctCriteria(org.hibernate.Session session, Class<?> persistentClass)Creates aCriteriaquery for the specified persistent class.- Parameters:
session- the Hibernate sessionpersistentClass- the class for which to create a criteria query- Returns:
- a
Criteriawhich you can build upon
-
addOrder
public static org.hibernate.Criteria addOrder(org.hibernate.Criteria criteria, String orderClause)Adds the specified order clause to an existingCriteria, returning the criteria that was passed in.The
orderClauseshould contain a comma-separated list of properties optionally followed by an order designator, which must beascordesc. If neither ascending nor descending is specified, ascending order is used. For example, the order clause for listing people by descending date of birth, then ascending last name, and finally ascending first name is:dateOfBirth desc, lastName, firstName
- Parameters:
criteria- an existingCriteriato add ordering toorderClause- the order specification- Returns:
- the same
criteriainstance passed in, to allow building upon it
-
-