Methods Summary |
---|
public org.hibernate.sql.Update | addColumn(java.lang.String columnName)
return addColumn(columnName, "?");
|
public org.hibernate.sql.Update | addColumn(java.lang.String columnName, java.lang.String value)
columns.put(columnName, value);
return this;
|
public org.hibernate.sql.Update | addColumn(java.lang.String columnName, java.lang.Object value, org.hibernate.type.LiteralType type)
return addColumn( columnName, type.objectToSQLString(value, dialect) );
|
public org.hibernate.sql.Update | addColumns(java.lang.String[] columnNames, java.lang.String value)
for ( int i=0; i<columnNames.length; i++ ) {
addColumn( columnNames[i], value );
}
return this;
|
public org.hibernate.sql.Update | addColumns(java.lang.String[] columnNames)
for ( int i=0; i<columnNames.length; i++ ) {
addColumn( columnNames[i] );
}
return this;
|
public org.hibernate.sql.Update | addColumns(java.lang.String[] columnNames, boolean[] updateable)
for ( int i=0; i<columnNames.length; i++ ) {
if ( updateable[i] ) addColumn( columnNames[i] );
}
return this;
|
public org.hibernate.sql.Update | addWhereColumn(java.lang.String columnName)
return addWhereColumn(columnName, "=?");
|
public org.hibernate.sql.Update | addWhereColumn(java.lang.String columnName, java.lang.String value)
whereColumns.put(columnName, value);
return this;
|
public org.hibernate.sql.Update | addWhereColumns(java.lang.String[] columnNames)
for ( int i=0; i<columnNames.length; i++ ) {
addWhereColumn( columnNames[i] );
}
return this;
|
public org.hibernate.sql.Update | addWhereColumns(java.lang.String[] columnNames, java.lang.String value)
for ( int i=0; i<columnNames.length; i++ ) {
addWhereColumn( columnNames[i], value );
}
return this;
|
public org.hibernate.sql.Update | appendAssignmentFragment(java.lang.String fragment)
if ( assignments == null ) {
assignments = fragment;
}
else {
assignments += ", " + fragment;
}
return this;
|
public java.lang.String | getTableName()
return tableName;
|
public org.hibernate.sql.Update | setComment(java.lang.String comment)
this.comment = comment;
return this;
|
public org.hibernate.sql.Update | setPrimaryKeyColumnNames(java.lang.String[] primaryKeyColumnNames)
this.primaryKeyColumnNames = primaryKeyColumnNames;
return this;
|
public org.hibernate.sql.Update | setTableName(java.lang.String tableName)
this.tableName = tableName;
return this;
|
public org.hibernate.sql.Update | setVersionColumnName(java.lang.String versionColumnName)
this.versionColumnName = versionColumnName;
return this;
|
public org.hibernate.sql.Update | setWhere(java.lang.String where)
this.where=where;
return this;
|
public java.lang.String | toStatementString()
StringBuffer buf = new StringBuffer( (columns.size() * 15) + tableName.length() + 10 );
if ( comment!=null ) {
buf.append( "/* " ).append( comment ).append( " */ " );
}
buf.append( "update " ).append( tableName ).append( " set " );
boolean assignmentsAppended = false;
Iterator iter = columns.entrySet().iterator();
while ( iter.hasNext() ) {
Map.Entry e = (Map.Entry) iter.next();
buf.append( e.getKey() ).append( '=" ).append( e.getValue() );
if ( iter.hasNext() ) {
buf.append( ", " );
}
assignmentsAppended = true;
}
if ( assignments != null ) {
if ( assignmentsAppended ) {
buf.append( ", " );
}
buf.append( assignments );
}
boolean conditionsAppended = false;
if ( primaryKeyColumnNames != null || where != null || !whereColumns.isEmpty() || versionColumnName != null ) {
buf.append( " where " );
}
if ( primaryKeyColumnNames != null ) {
buf.append( StringHelper.join( "=? and ", primaryKeyColumnNames ) ).append( "=?" );
conditionsAppended = true;
}
if ( where != null ) {
if ( conditionsAppended ) {
buf.append( " and " );
}
buf.append( where );
conditionsAppended = true;
}
iter = whereColumns.entrySet().iterator();
while ( iter.hasNext() ) {
final Map.Entry e = (Map.Entry) iter.next();
if ( conditionsAppended ) {
buf.append( " and " );
}
buf.append( e.getKey() ).append( e.getValue() );
conditionsAppended = true;
}
if ( versionColumnName != null ) {
if ( conditionsAppended ) {
buf.append( " and " );
}
buf.append( versionColumnName ).append( "=?" );
}
return buf.toString();
|