Methods Summary |
---|
public org.hibernate.sql.SimpleSelect | addColumn(java.lang.String columnName)
columns.add(columnName);
//aliases.put( columnName, DEFAULT_ALIAS.toAliasString(columnName) );
return this;
|
public org.hibernate.sql.SimpleSelect | addColumn(java.lang.String columnName, java.lang.String alias)
columns.add(columnName);
aliases.put(columnName, alias);
return this;
|
public org.hibernate.sql.SimpleSelect | addColumns(java.lang.String[] columnNames, java.lang.String[] columnAliases)
for ( int i=0; i<columnNames.length; i++ ) {
if ( columnNames[i]!=null ) {
addColumn( columnNames[i], columnAliases[i] );
}
}
return this;
|
public org.hibernate.sql.SimpleSelect | addColumns(java.lang.String[] columns, java.lang.String[] aliases, boolean[] ignore)
for ( int i=0; i<ignore.length; i++ ) {
if ( !ignore[i] && columns[i]!=null ) {
addColumn( columns[i], aliases[i] );
}
}
return this;
|
public org.hibernate.sql.SimpleSelect | addColumns(java.lang.String[] columnNames)
for ( int i=0; i<columnNames.length; i++ ) {
if ( columnNames[i]!=null ) addColumn( columnNames[i] );
}
return this;
|
public org.hibernate.sql.SimpleSelect | addCondition(java.lang.String lhs, java.lang.String op, java.lang.String rhs)
and();
whereTokens.add( lhs + ' " + op + ' " + rhs );
return this;
|
public org.hibernate.sql.SimpleSelect | addCondition(java.lang.String lhs, java.lang.String condition)
and();
whereTokens.add( lhs + ' " + condition );
return this;
|
public org.hibernate.sql.SimpleSelect | addCondition(java.lang.String[] lhs, java.lang.String op, java.lang.String[] rhs)
for ( int i=0; i<lhs.length; i++ ) {
addCondition( lhs[i], op, rhs[i] );
}
return this;
|
public org.hibernate.sql.SimpleSelect | addCondition(java.lang.String[] lhs, java.lang.String condition)
for ( int i=0; i<lhs.length; i++ ) {
if ( lhs[i]!=null ) addCondition( lhs[i], condition );
}
return this;
|
public org.hibernate.sql.SimpleSelect | addWhereToken(java.lang.String token)
whereTokens.add(token);
return this;
|
private void | and()
if ( whereTokens.size()>0 ) {
whereTokens.add("and");
}
|
public org.hibernate.sql.SimpleSelect | setComment(java.lang.String comment)
this.comment = comment;
return this;
|
public org.hibernate.sql.SimpleSelect | setLockMode(org.hibernate.LockMode lockMode)
this.lockMode = lockMode;
return this;
|
public org.hibernate.sql.SimpleSelect | setOrderBy(java.lang.String orderBy)
this.orderBy = orderBy;
return this;
|
public org.hibernate.sql.SimpleSelect | setTableName(java.lang.String tableName)
this.tableName = tableName;
return this;
|
public java.lang.String | toStatementString()
StringBuffer buf = new StringBuffer(
columns.size()*10 +
tableName.length() +
whereTokens.size() * 10 +
10
);
if ( comment!=null ) {
buf.append("/* ").append(comment).append(" */ ");
}
buf.append("select ");
Set uniqueColumns = new HashSet();
Iterator iter = columns.iterator();
boolean appendComma = false;
while ( iter.hasNext() ) {
String col = (String) iter.next();
String alias = (String) aliases.get(col);
if ( uniqueColumns.add(alias==null ? col : alias) ) {
if (appendComma) buf.append(", ");
buf.append(col);
if ( alias!=null && !alias.equals(col) ) {
buf.append(" as ")
.append(alias);
}
appendComma = true;
}
}
buf.append(" from ")
.append( dialect.appendLockHint(lockMode, tableName) );
if ( whereTokens.size() > 0 ) {
buf.append(" where ")
.append( toWhereClause() );
}
if (orderBy!=null) buf.append(orderBy);
if (lockMode!=null) {
buf.append( dialect.getForUpdateString(lockMode) );
}
return dialect.transformSelectString( buf.toString() );
|
public java.lang.String | toWhereClause()
StringBuffer buf = new StringBuffer( whereTokens.size() * 5 );
Iterator iter = whereTokens.iterator();
while ( iter.hasNext() ) {
buf.append( iter.next() );
if ( iter.hasNext() ) buf.append(' ");
}
return buf.toString();
|