org.hibernate.envers.tools.query
Class QueryBuilder

java.lang.Object
  extended by org.hibernate.envers.tools.query.QueryBuilder

public class QueryBuilder
extends Object

A class for incrementaly building a HQL query.


Constructor Summary
QueryBuilder(String entityName, String alias)
           
 
Method Summary
 void addFrom(String entityName, String alias)
          Add an entity from which to select.
 void addOrder(String propertyName, boolean ascending)
           
 void addProjection(String function, String propertyName, boolean distinct)
           
 void addProjection(String function, String propertyName, boolean distinct, boolean addAlias)
           
 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.
 QueryBuilder deepCopy()
           
 Parameters getRootParameters()
           
 QueryBuilder newSubQueryBuilder()
           
 QueryBuilder newSubQueryBuilder(String entityName, String alias)
           
 Query toQuery(Session session)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryBuilder

public QueryBuilder(String entityName,
                    String alias)
Parameters:
entityName - Main entity which should be selected.
alias - Alias of the entity
Method Detail

deepCopy

public QueryBuilder deepCopy()

addFrom

public void addFrom(String entityName,
                    String alias)
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.

newSubQueryBuilder

public QueryBuilder newSubQueryBuilder()
Returns:
A sub-query builder for the same entity (with an auto-generated alias). The sub-query can be later used as a value of a parameter.

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

addOrder

public void addOrder(String propertyName,
                     boolean ascending)

addProjection

public void addProjection(String function,
                          String propertyName,
                          boolean distinct)

addProjection

public void addProjection(String function,
                          String propertyName,
                          boolean distinct,
                          boolean addAlias)

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.

toQuery

public Query toQuery(Session session)


Copyright © 2001-2015 Red Hat, Inc. All Rights Reserved.