com.j256.ormlite.stmt.query.SetValue Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ormlite-core Show documentation
Show all versions of ormlite-core Show documentation
Lightweight Object Relational Model (ORM) for persisting objects to SQL databases.
package com.j256.ormlite.stmt.query;
import java.sql.SQLException;
import com.j256.ormlite.field.FieldType;
import com.j256.ormlite.stmt.ArgumentHolder;
import com.j256.ormlite.stmt.NullArgHolder;
import com.j256.ormlite.stmt.StatementBuilder;
/**
* Internal class handling the SQL SET part used by UPDATE statements. Used by
* {@link StatementBuilder#updateColumnValue(String, Object)}.
*
*
* It's not a comparison per se but does have a columnName = value form so it works.
*
*
* @author graywatson
*/
public class SetValue extends BaseComparison {
/**
* Special value in case we are trying to set a field to null. We can't just use the null value because it looks
* like the argument has not been set in the base class.
*/
private static final ArgumentHolder nullValue = new NullArgHolder();
public SetValue(String columnName, FieldType fieldType, Object value) throws SQLException {
super(columnName, fieldType, (value == null ? nullValue : value), false);
}
@Override
public void appendOperation(StringBuilder sb) {
sb.append("= ");
}
}