Class ByHqlStatic
java.lang.Object
edu.internet2.middleware.grouper.hibernate.ByHqlStatic
- All Implemented Interfaces:
HqlQuery
for simple HQL, 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.
-
Method Summary
Modifier and TypeMethodDescriptionassignBatchPreExecuteUpdateQuery
(String theBatchPreExecuteUpdateQuery) if batch deleting, run this execute update first.assignConvertHqlColumnsToObject
(boolean theConvert) if use resulttransformer to change columns to objectcreateQuery
(String theHqlQuery) set the query to runlong
deleteInBatches
(Class<?> idType, String hqlClassNameToDelete, String columnNameOfId) GRP-1439: remove records with a max number and loop so it doesnt fail select ids in batches of 10k delete records in batches of 100 Note this should be setup to select a list of scalar String ids.void
call hql executeUpdate, e.g.int
call hql executeUpdate, e.g.<R> List<R>
call hql list result e.g.<K,
V> Map<K, V> call hql 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 querysetCacheable
(Boolean cacheable) assign if this query is cacheable or not.setCacheRegion
(String cacheRegion) cache region for cachesetCollectionInClause
(StringBuilder query, Collection<?> params) append a certain number of params, and commas, and attach the data.assign data to the bind varsetGrouperTransactionType
(GrouperTransactionType theGrouperTransactionType) assign a different grouperTransactionType (e.g.setInteger
(String bindVarName, Integer value) assign data to the bind varassign data to the bind varassign data to the bind varassign data to the bind varsetTimestamp
(String bindVarName, Date value) assign data to the bind vartoString()
string value for error handling<Q> Q
uniqueResult
(Class<Q> returnType) call hql unique result (returns one or null) e.g.
-
Method Details
-
assignConvertHqlColumnsToObject
if use resulttransformer to change columns to object- Parameters:
theConvert
-- Returns:
- this for chaining
-
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
-
toString
string value for error handling -
assignBatchPreExecuteUpdateQuery
if batch deleting, run this execute update first. note, the query must end with " in " or " in"- Parameters:
theBatchPreExecuteUpdateQuery
-- Returns:
- this for chaining
-
createQuery
set the query to run- Parameters:
theHqlQuery
-- Returns:
- this object for chaining
-
setCacheRegion
cache region for cache- Parameters:
cacheRegion
- the cacheRegion to set- Returns:
- this object for chaining
-
setString
assign data to the bind var -
setTimestamp
assign data to the bind var- Parameters:
bindVarName
-value
-- Returns:
- this object for chaining
-
setLong
assign data to the bind var- Parameters:
bindVarName
-value
- is long, primitive so not null- Returns:
- this object for chaining
-
setDouble
assign data to the bind var- Parameters:
bindVarName
-value
- is double- Returns:
- this object for chaining
-
setInteger
assign data to the bind var- Parameters:
bindVarName
-value
- is long, primitive so not null- Returns:
- this object for chaining
-
setScalar
assign data to the bind var -
setCollectionInClause
append a certain number of params, and commas, and attach the data. Note any params before the in clause need to be already attached, since these will attach now (ordering issue)- Parameters:
query
-params
- collection of params, note, this is for an inclause, so it cant be null- Returns:
- this for chaining
-
uniqueResult
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:
Q
- is the template- Parameters:
returnType
- type of the result (in future can use this for typecasting)- Returns:
- the object or null if none found
- Throws:
GrouperDAOException
-
list
call hql list result 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:
R
- is the template- Parameters:
returnType
- type of the result (can typecast)- Returns:
- the list or the empty list if not found (never null)
- Throws:
GrouperDAOException
-
listSet
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)- 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, String keyPropertyName) throws GrouperDAOException call hql 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)keyClass
- 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
-
deleteInBatches
GRP-1439: remove records with a max number and loop so it doesnt fail select ids in batches of 10k delete records in batches of 100 Note this should be setup to select a list of scalar String ids. It will page it- Parameters:
idType
- type of id which can be String or longhqlClassNameToDelete
-columnNameOfId
-- Returns:
- the total number of records deleted
-
executeUpdate
call hql executeUpdate, e.g. delete or update statement
- Throws:
GrouperDAOException
- TODO remove this in a new version of Grouper
-
executeUpdateInt
call hql executeUpdate, e.g. delete or update statement
- Returns:
- number of records affected
- Throws:
GrouperDAOException
-
options
add a paging/sorting/resultSetSize, etc to the query- Parameters:
queryOptions1
-- Returns:
- this for chaining
-