Class ByCriteriaStatic
java.lang.Object
edu.internet2.middleware.grouper.hibernate.ByCriteriaStatic
for simple criteria queries, use this instead of inverse of control.
this will do proper error handling and descriptive exception
handling. This will by default use the transaction modes
GrouperTransactionType.READONLY_OR_USE_EXISTING, and
GrouperTransactionType.READ_WRITE_OR_USE_EXISTING depending on
if a transaction is needed.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic int
query count exec queries, used for testing -
Method Summary
Modifier and TypeMethodDescription<T> List<T>
call hql unique result (returns one or null) e.g.<K,
V> Map<K, V> listMap
(Class<K> keyClass, Class<V> valueClass, org.hibernate.criterion.Criterion theCriterions, String keyPropertyName) call criteria list result, and put the results in map with the key as one of the fields<S> Set<S>
call hql list result, and put the results in an ordered set e.g.options
(QueryOptions queryOptions1) add a paging/sorting/resultSetSize, etc to the queryalias for queried classsetCacheable
(Boolean cacheable) assign if this query is cacheable or not.setCacheRegion
(String cacheRegion) cache region for cachesetEntityName
(String theEntityName) entity name if the object is mapped to more than one tablesetGrouperTransactionType
(GrouperTransactionType theGrouperTransactionType) assign a different grouperTransactionType (e.g.toString()
string value for error handling<T> T
uniqueResult
(Class<T> returnType, org.hibernate.criterion.Criterion theCriterions) call hql unique result (returns one or null) e.g.
-
Field Details
-
queryCountQueries
public static int queryCountQueriesquery count exec queries, used for testing
-
-
Method Details
-
setGrouperTransactionType
assign a different grouperTransactionType (e.g. for autonomous transactions)- Parameters:
theGrouperTransactionType
-- Returns:
- the same object for chaining
-
setCacheable
assign if this query is cacheable or not.- Parameters:
cacheable
- the cacheable to set- Returns:
- this object for chaining
-
listSet
public <S> Set<S> listSet(Class<S> returnType, org.hibernate.criterion.Criterion theCriterions) throws GrouperDAOException call hql list result, and put the results in an ordered set e.g. Set
groupTypeTupleDTOs = HibernateSession.byHqlStatic() .createQuery("from Hib3GroupTypeTupleDAO as gtt where gtt.groupUuid = :group") .setCacheable(false).setString("group", uuid).listSet(Hib3GroupTypeTupleDAO.class); - Type Parameters:
S
- is the template- Parameters:
returnType
- type of the result (can typecast)theCriterions
-- Returns:
- the ordered set or the empty set if not found (never null)
- Throws:
GrouperDAOException
-
listMap
public <K,V> Map<K,V> listMap(Class<K> keyClass, Class<V> valueClass, org.hibernate.criterion.Criterion theCriterions, String keyPropertyName) throws GrouperDAOException call criteria list result, and put the results in map with the key as one of the fields
- Type Parameters:
K
- is the template of the key of the mapV
- is the template of the value of the map- Parameters:
valueClass
- type of the result (can typecast)theCriterions
- are the criteria for the querykeyClass
- is the type of the key of the mapkeyPropertyName
- name of the javabeans property for the key in the map- Returns:
- the ordered set or the empty set if not found (never null)
- Throws:
GrouperDAOException
-
toString
string value for error handling -
options
add a paging/sorting/resultSetSize, etc to the query- Parameters:
queryOptions1
-- Returns:
- this for chaining
-
setCacheRegion
cache region for cache- Parameters:
cacheRegion
- the cacheRegion to set- Returns:
- this object for chaining
-
setAlias
alias for queried class- Parameters:
theAlias
- the cacheRegion to set- Returns:
- this object for chaining
-
uniqueResult
public <T> T uniqueResult(Class<T> returnType, org.hibernate.criterion.Criterion theCriterions) throws GrouperDAOException call hql unique result (returns one or null) e.g. Hib3GroupDAO hib3GroupDAO = HibernateSession.byHqlStatic() .createQuery("from Hib3GroupDAO as g where g.uuid = :uuid") .setCacheable(false) .setCacheRegion(KLASS + ".Exists") .setString("uuid", uuid).uniqueResult(Hib3GroupDAO.class);
- Type Parameters:
T
- is the template- Parameters:
returnType
- type of the result (in future can use this for typecasting)theCriterions
- are the criterions to use (pack multiple with HibUtils.listCrit())- Returns:
- the object or null if none found
- Throws:
GrouperDAOException
-
list
public <T> List<T> list(Class<T> returnType, org.hibernate.criterion.Criterion theCriterions) throws GrouperDAOException call hql unique result (returns one or null) e.g. List
hib3GroupTypeTupleDAOs = HibernateSession.byHqlStatic() .createQuery("from Hib3GroupTypeTupleDAO as gtt where gtt.groupUuid = :group") .setCacheable(false).setString("group", uuid).list(Hib3GroupTypeTupleDAO.class); - Type Parameters:
T
- is the template- Parameters:
returnType
- type of the result (can typecast)theCriterions
- are the criterions to use (pack multiple with HibUtils.listCrit())- Returns:
- the list or the empty list if not found (never null)
- Throws:
GrouperDAOException
-
setEntityName
entity name if the object is mapped to more than one table- Parameters:
theEntityName
- the entity name of the object- Returns:
- this object for chaining
-