Methods Summary |
---|
public void | addOrderBy(java.lang.String orderByString)
if ( orderBy.length() > 0 ) orderBy.append(", ");
orderBy.append(orderByString);
|
public void | addSelectColumn(java.lang.String columnName, java.lang.String alias)
addSelectFragmentString(columnName + ' " + alias);
|
public void | addSelectFragmentString(java.lang.String fragment)
if ( fragment.length()>0 && fragment.charAt(0)=='," ) fragment = fragment.substring(1);
fragment = fragment.trim();
if ( fragment.length()>0 ) {
if ( select.length()>0 ) select.append(", ");
select.append(fragment);
}
|
private static void | appendTokens(java.lang.StringBuffer buf, java.util.Iterator iter)
boolean lastSpaceable=true;
boolean lastQuoted=false;
while ( iter.hasNext() ) {
String token = (String) iter.next();
boolean spaceable = !DONT_SPACE_TOKENS.contains(token);
boolean quoted = token.startsWith("'");
if (spaceable && lastSpaceable) {
if ( !quoted || !lastQuoted ) buf.append(' ");
}
lastSpaceable = spaceable;
buf.append(token);
lastQuoted = token.endsWith("'");
}
|
public org.hibernate.sql.QuerySelect | copy()
QuerySelect copy = new QuerySelect(dialect);
copy.joins = this.joins.copy();
copy.select.append( this.select.toString() );
copy.where.append( this.where.toString() );
copy.groupBy.append( this.groupBy.toString() );
copy.orderBy.append( this.orderBy.toString() );
copy.having.append( this.having.toString() );
copy.comment = this.comment;
copy.distinct = this.distinct;
return copy;
|
public JoinFragment | getJoinFragment()
return joins;
|
public void | prependWhereConditions(java.lang.String conditions)
if (where.length() > 0) {
where.insert(0, conditions + " and ");
}
else {
where.append(conditions);
}
|
public void | setComment(java.lang.String comment)
this.comment = comment;
|
public void | setDistinct(boolean distinct)
this.distinct = distinct;
|
public void | setGroupByTokens(java.util.Iterator tokens)
//if ( groupBy.length()>0 ) groupBy.append(" and ");
appendTokens(groupBy, tokens);
|
public void | setHavingTokens(java.util.Iterator tokens)
//if ( having.length()>0 ) having.append(" and ");
appendTokens(having, tokens);
|
public void | setOrderByTokens(java.util.Iterator tokens)
//if ( orderBy.length()>0 ) orderBy.append(" and ");
appendTokens(orderBy, tokens);
|
public void | setWhereTokens(java.util.Iterator tokens)
//if ( conjunctiveWhere.length()>0 ) conjunctiveWhere.append(" and ");
appendTokens(where, tokens);
|
public java.lang.String | toQueryString()
StringBuffer buf = new StringBuffer(50);
if (comment!=null) buf.append("/* ").append(comment).append(" */ ");
buf.append("select ");
if (distinct) buf.append("distinct ");
String from = joins.toFromFragmentString();
if ( from.startsWith(",") ) {
from = from.substring(1);
}
else if ( from.startsWith(" inner join") ){
from = from.substring(11);
}
buf.append( select.toString() )
.append(" from")
.append(from);
String outerJoinsAfterWhere = joins.toWhereFragmentString().trim();
String whereConditions = where.toString().trim();
boolean hasOuterJoinsAfterWhere = outerJoinsAfterWhere.length() > 0;
boolean hasWhereConditions = whereConditions.length() > 0;
if (hasOuterJoinsAfterWhere || hasWhereConditions) {
buf.append(" where ");
if (hasOuterJoinsAfterWhere) {
buf.append( outerJoinsAfterWhere.substring(4) );
}
if (hasWhereConditions) {
if (hasOuterJoinsAfterWhere) {
buf.append(" and (");
}
buf.append(whereConditions);
if (hasOuterJoinsAfterWhere) {
buf.append(")");
}
}
}
if ( groupBy.length() > 0 ) buf.append(" group by ").append( groupBy.toString() );
if ( having.length() > 0 ) buf.append(" having ").append( having.toString() );
if ( orderBy.length() > 0 ) buf.append(" order by ").append( orderBy.toString() );
return dialect.transformSelectString( buf.toString() );
|