Methods Summary |
---|
public org.hibernate.sql.InsertSelect | addColumn(java.lang.String columnName)
columnNames.add( columnName );
return this;
|
public org.hibernate.sql.InsertSelect | addColumns(java.lang.String[] columnNames)
for ( int i = 0; i < columnNames.length; i++ ) {
this.columnNames.add( columnNames[i] );
}
return this;
|
public org.hibernate.sql.InsertSelect | setComment(java.lang.String comment)
this.comment = comment;
return this;
|
public org.hibernate.sql.InsertSelect | setSelect(Select select)
this.select = select;
return this;
|
public org.hibernate.sql.InsertSelect | setTableName(java.lang.String tableName)
this.tableName = tableName;
return this;
|
public java.lang.String | toStatementString()
if ( tableName == null ) throw new HibernateException( "no table name defined for insert-select" );
if ( select == null ) throw new HibernateException( "no select defined for insert-select" );
StringBuffer buf = new StringBuffer( (columnNames.size() * 15) + tableName.length() + 10 );
if ( comment!=null ) {
buf.append( "/* " ).append( comment ).append( " */ " );
}
buf.append( "insert into " ).append( tableName );
if ( !columnNames.isEmpty() ) {
buf.append( " (" );
Iterator itr = columnNames.iterator();
while ( itr.hasNext() ) {
buf.append( itr.next() );
if ( itr.hasNext() ) {
buf.append( ", " );
}
}
buf.append( ")" );
}
buf.append( ' " ).append( select.toStatementString() );
return buf.toString();
|