T - the class that is being queried forpublic class TypedQueryBuilder<T> extends Object
| Modifier and Type | Field and Description |
|---|---|
protected Map<String,Object> |
paramMap |
protected List<TQRestriction> |
restrictions |
protected String |
rootAlias |
protected Class<T> |
rootClass |
| Constructor and Description |
|---|
TypedQueryBuilder(Class<T> rootClass,
String rootAlias)
Creates a new TypedQueryBuilder that will utilize the rootAlias as the named object of the class
|
| Modifier and Type | Method and Description |
|---|---|
TypedQueryBuilder<T> |
addRestriction(String expression,
String operation,
Object parameter)
Adds a simple restriction to the query.
|
TypedQueryBuilder<T> |
addRestriction(TQRestriction restriction)
Adds an explicit TQRestriction object.
|
protected void |
fillParameterMap(javax.persistence.TypedQuery<?> q) |
Map<String,Object> |
getParamMap() |
protected StringBuilder |
getSelectClause(StringBuilder sb,
boolean count)
Adds the select query from
toQueryString() |
javax.persistence.TypedQuery<Long> |
toCountQuery(javax.persistence.EntityManager em) |
javax.persistence.TypedQuery<T> |
toQuery(javax.persistence.EntityManager em)
Returns a TypedQuery that represents this builder object.
|
String |
toQueryString()
Generates the query string based on the current contents of this builder.
|
String |
toQueryString(boolean count)
Generates the query string based on the current contents of this builder.
|
protected String rootAlias
protected List<TQRestriction> restrictions
public TypedQueryBuilder<T> addRestriction(String expression, String operation, Object parameter)
expression - operation - parameter - public TypedQueryBuilder<T> addRestriction(TQRestriction restriction)
restriction - public String toQueryString()
toQuery(EntityManager),
which will automatically generate the TypedQuery and populate the required parameters.public String toQueryString(boolean count)
toQuery(EntityManager),
which will automatically generate the TypedQuery and populate the required parameters.
If you are using this as a COUNT query, you should look at the corresponding toCountQuery(EntityManager)whether - or not the resulting query string should be used as a count query or notprotected StringBuilder getSelectClause(StringBuilder sb, boolean count)
toQueryString()public javax.persistence.TypedQuery<T> toQuery(javax.persistence.EntityManager em)
em - public javax.persistence.TypedQuery<Long> toCountQuery(javax.persistence.EntityManager em)
protected void fillParameterMap(javax.persistence.TypedQuery<?> q)
Copyright © 2014. All Rights Reserved.