Methods Summary |
---|
public org.hibernate.sql.SelectFragment | addColumn(java.lang.String columnName)
addColumn(null, columnName);
return this;
|
public org.hibernate.sql.SelectFragment | addColumn(java.lang.String tableAlias, java.lang.String columnName)
return addColumn(tableAlias, columnName, columnName);
|
public org.hibernate.sql.SelectFragment | addColumn(java.lang.String tableAlias, java.lang.String columnName, java.lang.String columnAlias)
columns.add( StringHelper.qualify(tableAlias, columnName) );
//columns.add(columnName);
//aliases.add(tableAlias);
columnAliases.add(columnAlias);
return this;
|
public org.hibernate.sql.SelectFragment | addColumns(java.lang.String tableAlias, java.lang.String[] columnNames)
for (int i=0; i<columnNames.length; i++) addColumn( tableAlias, columnNames[i] );
return this;
|
public org.hibernate.sql.SelectFragment | addColumns(java.lang.String tableAlias, java.lang.String[] columnNames, java.lang.String[] columnAliases)
for (int i=0; i<columnNames.length; i++) {
if ( columnNames[i]!=null ) addColumn( tableAlias, columnNames[i], columnAliases[i] );
}
return this;
|
public org.hibernate.sql.SelectFragment | addColumns(java.lang.String[] columnNames)
for (int i=0; i<columnNames.length; i++) addColumn( columnNames[i] );
return this;
|
public org.hibernate.sql.SelectFragment | addFormula(java.lang.String tableAlias, java.lang.String formula, java.lang.String formulaAlias)
columns.add( StringHelper.replace(formula, Template.TEMPLATE, tableAlias) );
columnAliases.add(formulaAlias);
return this;
|
public org.hibernate.sql.SelectFragment | addFormulas(java.lang.String tableAlias, java.lang.String[] formulas, java.lang.String[] formulaAliases)
for ( int i=0; i<formulas.length; i++ ) {
if ( formulas[i]!=null ) addFormula( tableAlias, formulas[i], formulaAliases[i] );
}
return this;
|
public org.hibernate.sql.SelectFragment | setExtraSelectList(java.lang.String extraSelectList)
this.extraSelectList = extraSelectList;
return this;
|
public org.hibernate.sql.SelectFragment | setExtraSelectList(CaseFragment caseFragment, java.lang.String fragmentAlias)
setExtraSelectList( caseFragment.setReturnColumnName(fragmentAlias, suffix).toFragmentString() );
return this;
|
public org.hibernate.sql.SelectFragment | setSuffix(java.lang.String suffix)
this.suffix = suffix;
return this;
|
public org.hibernate.sql.SelectFragment | setUsedAliases(java.lang.String[] aliases)
usedAliases = aliases;
return this;
|
public java.lang.String | toFragmentString()
StringBuffer buf = new StringBuffer( columns.size() * 10 );
Iterator iter = columns.iterator();
Iterator columnAliasIter = columnAliases.iterator();
//HashMap columnsUnique = new HashMap();
HashSet columnsUnique = new HashSet();
if (usedAliases!=null) columnsUnique.addAll( Arrays.asList(usedAliases) );
while ( iter.hasNext() ) {
String column = (String) iter.next();
String columnAlias = (String) columnAliasIter.next();
//TODO: eventually put this back in, once we think all is fixed
//Object otherAlias = columnsUnique.put(qualifiedColumn, columnAlias);
/*if ( otherAlias!=null && !columnAlias.equals(otherAlias) ) {
throw new AssertionFailure("bug in Hibernate SQL alias generation");
}*/
if ( columnsUnique.add(columnAlias) ) {
buf.append(", ")
.append(column)
.append(" as ");
if (suffix==null) {
buf.append(columnAlias);
}
else {
buf.append( new Alias(suffix).toAliasString(columnAlias) );
}
}
}
if (extraSelectList!=null) {
buf.append(", ")
.append(extraSelectList);
}
return buf.toString();
|