public final class CriteriaQueryGenerator extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
CriteriaQueryGenerator.AuthorizationTokenType |
| Constructor and Description |
|---|
CriteriaQueryGenerator(org.rhq.core.domain.criteria.Criteria criteria) |
CriteriaQueryGenerator(org.rhq.core.domain.auth.Subject subject,
org.rhq.core.domain.criteria.Criteria criteria) |
| Modifier and Type | Method and Description |
|---|---|
void |
alterCountProjection(String countProjection)
Sometimes the altered projection (
alterProjection(String)) might cause the result set to have different
number of results than the default/unaltered projection. |
void |
alterProjection(String projection)
If you want to return something other than the list of entities represented by the passed Criteria object,
you can alter the projection here to return a customized subset or superset of data.
|
static String |
getCleansedFieldName(Field field,
int leadingCharsToStrip) |
javax.persistence.Query |
getCountQuery(javax.persistence.EntityManager em) |
List<String> |
getFetchFields(org.rhq.core.domain.criteria.Criteria criteria) |
Map<String,Object> |
getFilterFields(org.rhq.core.domain.criteria.Criteria criteria) |
List<Field> |
getJoinFetchFields()
Note: This method should only be called after
getQueryString(boolean)} because it is
that method where the persistentBagFields property is initialized. |
static org.rhq.core.domain.util.PageControl |
getPageControl(org.rhq.core.domain.criteria.Criteria criteria) |
String |
getParameterReplacedQuery(boolean countQuery) |
List<Field> |
getPersistentBagFields()
Note: This method should only be called after
getQueryString(boolean)} because it is
that method where the persistentBagFields property is initialized. |
javax.persistence.Query |
getQuery(javax.persistence.EntityManager em) |
String |
getQueryString(boolean countQuery) |
boolean |
isProjectionAltered() |
static void |
main(String[] args) |
void |
setAuthorizationBundleFragment(CriteriaQueryGenerator.AuthorizationTokenType type,
int subjectId) |
void |
setAuthorizationBundleFragment(CriteriaQueryGenerator.AuthorizationTokenType type,
int subjectId,
String fragment) |
void |
setAuthorizationCustomConditionFragment(String fragment) |
void |
setAuthorizationResourceFragment(CriteriaQueryGenerator.AuthorizationTokenType type,
int subjectId) |
void |
setAuthorizationResourceFragment(CriteriaQueryGenerator.AuthorizationTokenType type,
String fragment,
int subjectId) |
void |
setGroupByClause(String groupByClause)
The groupBy clause can be set if and only if the projection is altered.
|
void |
setHavingClause(String havingClause)
The having clause can be set if and only if the groupBy clause is set.
|
static void |
testAlertCriteria() |
static void |
testInheritanceCriteria() |
static void |
testResourceCriteria() |
static void |
testResourceGroupCriteria() |
static void |
testSubjectCriteria() |
public CriteriaQueryGenerator(org.rhq.core.domain.criteria.Criteria criteria)
public CriteriaQueryGenerator(org.rhq.core.domain.auth.Subject subject,
org.rhq.core.domain.criteria.Criteria criteria)
public void setAuthorizationCustomConditionFragment(String fragment)
public void setAuthorizationResourceFragment(CriteriaQueryGenerator.AuthorizationTokenType type, int subjectId)
public void setAuthorizationResourceFragment(CriteriaQueryGenerator.AuthorizationTokenType type, String fragment, int subjectId)
public void setAuthorizationBundleFragment(CriteriaQueryGenerator.AuthorizationTokenType type, int subjectId)
public void setAuthorizationBundleFragment(CriteriaQueryGenerator.AuthorizationTokenType type, int subjectId, String fragment)
public String getParameterReplacedQuery(boolean countQuery)
public String getQueryString(boolean countQuery)
public static String getCleansedFieldName(Field field, int leadingCharsToStrip)
public Map<String,Object> getFilterFields(org.rhq.core.domain.criteria.Criteria criteria)
public List<Field> getPersistentBagFields()
getQueryString(boolean)} because it is
that method where the persistentBagFields property is initialized.public List<Field> getJoinFetchFields()
getQueryString(boolean)} because it is
that method where the persistentBagFields property is initialized.
The elements of the returned list are a (sub)set of the fields that the criteria object specified to be fetched
(using the fetchXXX() methods). If the CriteriaQueryRunner is not set to automatically fetch all the
fields, you need to manually initialize these fields by for example using
CriteriaQueryRunner.initFetchFields(Object) method on each of the results.alterProjection(String) for special attention you need to make when
mixing fetching fields and altered projection.public void alterProjection(String projection)
CriteriaQueryRunner.initFetchFields(Object) method for each object in the results (for which you need
to instantiate the CriteriaQueryRunner with automatic fetching switched OFF). Note that this will
NOT work on the composite object itself. You need to pass an instance of the entity class to the
CriteriaQueryRunner.initFetchFields(Object) method.public void alterCountProjection(String countProjection)
alterProjection(String)) might cause the result set to have different
number of results than the default/unaltered projection. Leaving the count query in the default form could then
generate seemingly inconsistent results, where the data query and the count query wouldn't match up.
An example of a projection that might alter the number of results is the " distinct ..." projection that
would only return distinct results from a dataset, while the default count query (COUNT(*)) would produce the
count including duplicate results that were eliminated in the returned data.
In these cases one can also alter the count query to count the results the data query will return.countProjection - a complete JPQL fragment expressing the count expression (e.g.
COUNT(DISTINCT ...))public boolean isProjectionAltered()
public void setGroupByClause(String groupByClause)
public void setHavingClause(String havingClause)
public javax.persistence.Query getQuery(javax.persistence.EntityManager em)
public javax.persistence.Query getCountQuery(javax.persistence.EntityManager em)
public static void main(String[] args)
public static void testSubjectCriteria()
public static void testAlertCriteria()
public static void testInheritanceCriteria()
public static void testResourceGroupCriteria()
public static void testResourceCriteria()
public static org.rhq.core.domain.util.PageControl getPageControl(org.rhq.core.domain.criteria.Criteria criteria)
Copyright © 2008-2014 Red Hat, Inc.. All Rights Reserved.