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 Details

    • QueryBuilder

      public QueryBuilder(String entityName, String alias, SessionFactoryImplementor sessionFactory)
      Parameters:
      entityName - Main entity which should be selected.
      alias - Alias of the entity
      sessionFactory - Session factory
  • Method Details

    • 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(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)
    • addOrderFragment

      public void addOrderFragment(String alias, String orderByCollectionRole)
    • 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()
    • toQuery

      public Query toQuery(Session session)