Class QueryBuilder
- java.lang.Object
-
- org.hibernate.envers.internal.tools.query.QueryBuilder
-
public class QueryBuilder extends Object
A class for incrementally building a HQL query.
-
-
Constructor Summary
Constructors Constructor Description QueryBuilder(String entityName, String alias, SessionFactoryImplementor sessionFactory)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFrom(String entityName, String alias, boolean select)Add an entity from which to select.ParametersaddJoin(jakarta.persistence.criteria.JoinType joinType, String entityName, String alias, boolean select)voidaddOrder(String alias, String propertyName, boolean ascending, NullPrecedence nullPrecedence)voidaddOrderFragment(String alias, String orderByCollectionRole)ParametersaddParameters(String alias)voidaddProjection(String function, String alias, String propertyName, boolean distinct)voidaddProjection(Configuration configuration, Map<String,String> aliasToEntityNameMap, Map<String,String> aliasToComponentPropertyNameMap, AuditFunction function)protected static voidappendFunctionArgument(Configuration configuration, Map<String,String> aliasToEntityNameMap, Map<String,String> aliasToComponentPropertyNameMap, MutableInteger paramCounter, Map<String,Object> queryParamValues, String alias, StringBuilder expression, Object argument)voidbuild(StringBuilder sb, Map<String,Object> queryParamValues)Builds the given query, appending results to the given string buffer, and adding all query parameter values that are used to the map provided.QueryBuilderdeepCopy()StringgenerateAlias()StringgetAlias()StringgetRootAlias()ParametersgetRootParameters()QueryBuildernewSubQueryBuilder(String entityName, String alias)QuerytoQuery(Session session)
-
-
-
Constructor Detail
-
QueryBuilder
public QueryBuilder(String entityName, String alias, SessionFactoryImplementor sessionFactory)
- Parameters:
entityName- Main entity which should be selected.alias- Alias of the entitysessionFactory- Session factory
-
-
Method Detail
-
deepCopy
public QueryBuilder deepCopy()
-
getAlias
public String getAlias()
- Returns:
- the main alias of this query builder
-
addFrom
public void addFrom(String entityName, String alias, boolean select)
Add an entity from which to select.- Parameters:
entityName- Name of the entity from which to select.alias- Alias of the entity. Should be different than all other aliases.select- whether the entity should be selected
-
addJoin
public Parameters addJoin(jakarta.persistence.criteria.JoinType joinType, String entityName, String alias, boolean select)
-
generateAlias
public String generateAlias()
-
newSubQueryBuilder
public QueryBuilder newSubQueryBuilder(String entityName, String alias)
- Parameters:
entityName- Entity name, which will be the main entity for the sub-query.alias- Alias of the entity, which can later be used in parameters.- Returns:
- A sub-query builder for the given entity, with the given alias. The sub-query can be later used as a value of a parameter.
-
getRootParameters
public Parameters getRootParameters()
-
addParameters
public Parameters addParameters(String alias)
-
addOrder
public void addOrder(String alias, String propertyName, boolean ascending, NullPrecedence nullPrecedence)
-
addProjection
public void addProjection(String function, String alias, String propertyName, boolean distinct)
-
addProjection
public void addProjection(Configuration configuration, Map<String,String> aliasToEntityNameMap, Map<String,String> aliasToComponentPropertyNameMap, AuditFunction function)
-
appendFunctionArgument
protected static void appendFunctionArgument(Configuration configuration, Map<String,String> aliasToEntityNameMap, Map<String,String> aliasToComponentPropertyNameMap, MutableInteger paramCounter, Map<String,Object> queryParamValues, String alias, StringBuilder expression, Object argument)
-
build
public void build(StringBuilder sb, Map<String,Object> queryParamValues)
Builds the given query, appending results to the given string buffer, and adding all query parameter values that are used to the map provided.- Parameters:
sb- String builder to which the query will be appended.queryParamValues- Map to which name and values of parameters used in the query should be added.
-
getRootAlias
public String getRootAlias()
-
-