Class HQLQueryTranslater
java.lang.Object
com.atlassian.crowd.search.hibernate.HQLQueryTranslater
Translates implementation agnostic Queries into executable
Hibernate Query Language code.
Before you think this is an epic fail due the the existence of Hibernate criteria queries (CBQ), criteria queries can't do the join we want with user and user attribute classes without explicitly mapping the join in Hibernate (AFAIK). Experience has shown mapping joins for unbounded collections results in a performance nightmare when mutating the collection.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intprotected static final Stringprotected static final Stringprotected static final Stringstatic final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidappendBooleanTermRestrictionAsHQL(HQLQuery hql, Entity entityType, PropertyRestriction<Boolean> restriction, String attributeSharedAlias) protected voidappendComparableValueAsHQL(HQLQuery hql, PropertyRestriction restriction) protected voidappendComparableValueAsHQL(HQLQuery hql, PropertyRestriction restriction, Object normalizedValue) protected voidappendDateTermRestriction(HQLQuery hql, Entity entityType, PropertyRestriction<? extends Date> restriction, String attributeSharedAlias) protected voidappendDirectoryPropertyAsHQL(HQLQuery hql, PropertyRestriction restriction) protected voidappendEntityPropertyAsHQL(HQLQuery hql, Entity entityType, PropertyRestriction restriction, String attributeSharedAlias) protected voidappendEnumTermRestrictionAsHQL(HQLQuery hql, Entity entityType, PropertyRestriction<Enum> restriction, String attributeSharedAlias) protected voidappendGroupPropertyAsHQL(HQLQuery hql, PropertyRestriction restriction, String attributeSharedAlias) protected voidappendGroupTypeRestrictionAsHQL(HQLQuery hql, GroupType groupType) protected voidappendIsNullTermRestrictionAsHSQL(HQLQuery hql, Entity entityType, PropertyRestriction<?> restriction, String attributeSharedAlias) protected voidappendMultiTermRestrictionAsHQL(HQLQuery hql, Entity entityType, BooleanRestriction booleanRestriction) protected voidappendPropertyRestrictionAsHQL(HQLQuery hql, Entity entityType, SearchRestriction restriction, String attributeSharedAlias) protected voidappendQueryAsHQL(EntityQuery<?> query, HQLQuery hql) protected voidappendStringTermRestrictionAsHQL(HQLQuery hql, Entity entityType, PropertyRestriction<String> restriction, String attributeSharedAlias) protected voidappendStringValueAsHQL(HQLQuery hql, PropertyRestriction<String> restriction) protected voidappendTokenPropertyAsHQL(HQLQuery hql, PropertyRestriction restriction) protected voidappendUserPropertyAsHQL(HQLQuery hql, PropertyRestriction restriction, String attributeSharedAlias) asHQL(long directoryID, EntityQuery entityQuery) Translates an entity query into a HQLQuery.asHQL(long directoryID, MembershipQuery query) Translates a membership query into a HQLQuery.asHQL(long directoryID, MembershipQuery<?> query, boolean selectEntityToMatch) Translates a membership query into a HQLQuery.asHQL(EntityQuery entityQuery) Translates an entity query into a HQLQuery.intprotected HQLQuerynewQuery()voidsetOrBatchSize(int orBatchSize)
-
Field Details
-
HQL_USER_NAME
- See Also:
-
HQL_USER_EMAIL_ADDRESS
- See Also:
-
HQL_USER_FIRST_NAME
- See Also:
-
HQL_USER_LAST_NAME
- See Also:
-
HQL_USER_DISPLAY_NAME
- See Also:
-
HQL_USER_ACTIVE
- See Also:
-
HQL_USER_EXTERNAL_ID
- See Also:
-
HQL_CREATED_DATE
- See Also:
-
HQL_UPDATED_DATE
- See Also:
-
HQL_GROUP_NAME
- See Also:
-
HQL_GROUP_DESCRIPTION
- See Also:
-
HQL_GROUP_ACTIVE
- See Also:
-
HQL_GROUP_TYPE
- See Also:
-
HQL_GROUP_LOCAL
- See Also:
-
HQL_GROUP_EXTERNAL_ID
- See Also:
-
HQL_TOKEN_NAME
- See Also:
-
HQL_TOKEN_LAST_ACCESSED_TIME
- See Also:
-
HQL_TOKEN_DIRECTORY_ID
- See Also:
-
HQL_TOKEN_RANDOM_NUMBER
- See Also:
-
HQL_DIRECTORY_NAME
- See Also:
-
HQL_DIRECTORY_ACTIVE
- See Also:
-
HQL_DIRECTORY_TYPE
- See Also:
-
HQL_DIRECTORY_IMPLEMENTATION_CLASS
- See Also:
-
HQL_APPLICATION_NAME
- See Also:
-
HQL_APPLICATION_ACTIVE
- See Also:
-
HQL_APPLICATION_TYPE
- See Also:
-
HQL_ALIAS_NAME
- See Also:
-
HQL_ALIAS_APPLICATION_ID
- See Also:
-
HQL_ALIAS_USERNAME
- See Also:
-
HQL_ATTRIBUTE_NAME
- See Also:
-
HQL_ATTRIBUTE_LOWER_VALUE
- See Also:
-
HQL_ATTRIBUTE_NUMERIC_VALUE
- See Also:
-
HQL_ATTRIBUTE_ALIAS
- See Also:
-
HQL_DIRECTORY_ID
- See Also:
-
HQL_MEMBERSHIP_ALIAS
- See Also:
-
HQL_MEMBERSHIP_TYPE
- See Also:
-
HQL_MEMBERSHIP_GROUP_TYPE
- See Also:
-
DEFAULT_OR_BATCH_SIZE
protected static final int DEFAULT_OR_BATCH_SIZE- See Also:
-
HQL_AND
- See Also:
-
-
Constructor Details
-
HQLQueryTranslater
public HQLQueryTranslater() -
HQLQueryTranslater
public HQLQueryTranslater(int orBatchSize)
-
-
Method Details
-
asHQL
Translates a membership query into a HQLQuery. Query parameters are translated to JPA-style named parameters (e.g., :param1, :param2...).- Parameters:
query- a membership query- Returns:
- translated HQL query
-
asHQL
Translates a membership query into a HQLQuery. Query parameters are translated to JPA-style named parameters (e.g., :param1, :param2...).- Parameters:
query- a membership queryselectEntityToMatch- whether name of the entity to match should be returned, useful when there are multipleMembershipQuery.getEntityNamesToMatch()specified.- Returns:
- translated HQL query
-
newQuery
- Returns:
- a fresh instance of a HQLQuery
-
asHQL
Translates an entity query into a HQLQuery. Query parameters are translated to JPA-style positional parameters (e.g., ?1, ?2...).- Parameters:
entityQuery- an entity query- Returns:
- translated HQL query
-
asHQL
Translates an entity query into a HQLQuery. Query parameters are translated to JPA-style positional parameters (e.g., ?1, ?2...).- Parameters:
entityQuery- an entity query- Returns:
- Translated HQL query. If the result contains multiple entries it means that the original query was batched, and thus start indexes and limits might have been altered for merging purposes. If the result contains single query, then it's original query translated, with start index and limit preserved.
-
appendQueryAsHQL
-
appendPropertyRestrictionAsHQL
protected void appendPropertyRestrictionAsHQL(HQLQuery hql, Entity entityType, SearchRestriction restriction, @Nullable String attributeSharedAlias) -
appendIsNullTermRestrictionAsHSQL
protected void appendIsNullTermRestrictionAsHSQL(HQLQuery hql, Entity entityType, PropertyRestriction<?> restriction, @Nullable String attributeSharedAlias) -
appendDateTermRestriction
protected void appendDateTermRestriction(HQLQuery hql, Entity entityType, PropertyRestriction<? extends Date> restriction, @Nullable String attributeSharedAlias) -
appendBooleanTermRestrictionAsHQL
protected void appendBooleanTermRestrictionAsHQL(HQLQuery hql, Entity entityType, PropertyRestriction<Boolean> restriction, @Nullable String attributeSharedAlias) -
appendEnumTermRestrictionAsHQL
protected void appendEnumTermRestrictionAsHQL(HQLQuery hql, Entity entityType, PropertyRestriction<Enum> restriction, @Nullable String attributeSharedAlias) -
appendMultiTermRestrictionAsHQL
protected void appendMultiTermRestrictionAsHQL(HQLQuery hql, Entity entityType, BooleanRestriction booleanRestriction) -
appendStringTermRestrictionAsHQL
protected void appendStringTermRestrictionAsHQL(HQLQuery hql, Entity entityType, PropertyRestriction<String> restriction, @Nullable String attributeSharedAlias) -
appendEntityPropertyAsHQL
protected void appendEntityPropertyAsHQL(HQLQuery hql, Entity entityType, PropertyRestriction restriction, @Nullable String attributeSharedAlias) -
appendDirectoryPropertyAsHQL
-
appendTokenPropertyAsHQL
-
appendGroupTypeRestrictionAsHQL
-
appendGroupPropertyAsHQL
protected void appendGroupPropertyAsHQL(HQLQuery hql, PropertyRestriction restriction, @Nullable String attributeSharedAlias) -
appendUserPropertyAsHQL
protected void appendUserPropertyAsHQL(HQLQuery hql, PropertyRestriction restriction, @Nullable String attributeSharedAlias) -
appendStringValueAsHQL
-
appendComparableValueAsHQL
-
appendComparableValueAsHQL
protected void appendComparableValueAsHQL(HQLQuery hql, PropertyRestriction restriction, Object normalizedValue) -
setOrBatchSize
public void setOrBatchSize(int orBatchSize) -
getOrBatchSize
public int getOrBatchSize()
-