public class HQLExpression
extends java.lang.Object
HQLExpression hql = new HQLExpression("where ");
hql.append("a = ", true);
hql.append(" and b");
hql.append(' = ", true);
hql.toFinalExpression; -> "where a = ?0 and b = ?1"
Modifier and Type | Field and Description |
---|---|
private boolean |
endsWithSubst
true if the HQL expression ends with a substitution. |
private java.lang.StringBuilder |
lastPart
String builder to speed up sequential concatenations.
|
private java.util.List<java.lang.String> |
parts
Parts of the HQL expression separated by substitutions.
|
Constructor and Description |
---|
HQLExpression()
Create an empty HQL expression.
|
HQLExpression(HQLExpression starting)
Create an HQL expression starting with the specified sub-expression.
|
HQLExpression(java.lang.String starting)
Create an HQL expression starting with the specified sub-expression.
|
HQLExpression(java.lang.String starting,
boolean endsWithSubst)
Create an HQL expression starting with the specified sub-expression.
|
Modifier and Type | Method and Description |
---|---|
HQLExpression |
append(HQLExpression subExpression)
Append the expression with the specified sub-expression.
|
HQLExpression |
append(java.lang.String subExpression)
Append the expression with the specified sub-expression.
|
HQLExpression |
append(java.lang.String subExpression,
boolean endsWithSubst)
Append the expression with the specified sub-expression.
|
boolean |
isEmpty()
If this expression is empty.
|
java.lang.String |
toFinalExpression()
Returns the final form of the HQL expression with placeholders emitted.
|
java.lang.String |
toFinalExpression(boolean jpaStyle)
Returns the final form of the HQL expression with placeholders emitted.
|
java.lang.String |
toString()
Returns the string representation of this expression.
|
HQLExpression |
trim()
Trim the expression.
|
private void |
writeLastPart()
|
private java.util.List<java.lang.String> parts
private boolean endsWithSubst
true
if the HQL expression ends with a substitution.private java.lang.StringBuilder lastPart
null
or contain
the last part for parts
.public HQLExpression()
public HQLExpression(HQLExpression starting)
starting
- Staring sub-expression.public HQLExpression(java.lang.String starting)
starting
- Staring sub-expression.public HQLExpression(java.lang.String starting, boolean endsWithSubst)
starting
- Staring sub-expression.endsWithSubst
- true
if the starting sub-expression ends with a substitution.public HQLExpression append(java.lang.String subExpression)
subExpression
- Sub-expression to append.public HQLExpression append(java.lang.String subExpression, boolean endsWithSubst)
subExpression
- Sub-expression to append.endsWithSubst
- true
if the appended sub-expression ends with a substitution.public HQLExpression append(HQLExpression subExpression)
subExpression
- Sub-expression to append.public java.lang.String toFinalExpression()
public java.lang.String toFinalExpression(boolean jpaStyle)
jpsStyle
is
true
; otherwise, simple substitution placeholders (i.e., ?) are emitted.jpaStyle
- true
to emit JPA-style positional parameter placeholders;
false
to emit simple placeholders.public boolean isEmpty()
true
if this expression is empty.public HQLExpression trim()
public java.lang.String toString()
toString
in class java.lang.Object
private void writeLastPart()