public class UpdateBuilder
extends java.lang.Object
This is not thread safe.
UpdateBuilder builder = UpdateBuilder.newInstance(config);
builder.sql("update Emp");
builder.sql("set");
builder.sql("name = ").param(String.class, "SMIHT").sql(",");
builder.sql("salary = ").param(BigDecimal.class, new BigDecimal("1000"));
builder.sql("where");
builder.sql("id = ").param(int.class, 1000);
builder.execute();
update Emp set name = 'SMIHT', salary = 1000 where id = 10
| Modifier and Type | Method and Description |
|---|---|
void |
callerClassName(java.lang.String className)
Sets the caller class name.
|
void |
callerMethodName(java.lang.String methodName)
Sets the caller method name.
|
int |
execute()
Executes an SQL UPDATE statement.
|
Sql<?> |
getSql()
Returns the built SQL.
|
<P> UpdateBuilder |
literal(java.lang.Class<P> paramClass,
P param)
Appends a parameter as literal.
|
<E> UpdateBuilder |
literals(java.lang.Class<E> elementClass,
java.util.List<E> params)
Appends a parameter list as literal.
|
static UpdateBuilder |
newInstance(Config config)
Creates a new instance.
|
<P> UpdateBuilder |
param(java.lang.Class<P> paramClass,
P param)
Appends a parameter.
|
<E> UpdateBuilder |
params(java.lang.Class<E> elementClass,
java.util.List<E> params)
Appends a parameter list.
|
void |
queryTimeout(int queryTimeout)
Sets the query timeout limit in seconds.
|
UpdateBuilder |
removeLast()
Removes the last SQL fragment or parameter.
|
UpdateBuilder |
sql(java.lang.String sql)
Appends an SQL fragment.
|
void |
sqlLogType(SqlLogType sqlLogType)
Sets the SQL log format.
|
public static UpdateBuilder newInstance(Config config)
config - the configurationDomaNullPointerException - if config is nullpublic UpdateBuilder sql(java.lang.String sql)
sql - the SQL fragmentDomaNullPointerException - if sql is nullpublic UpdateBuilder removeLast()
public <P> UpdateBuilder param(java.lang.Class<P> paramClass, P param)
The parameter type must be one of basic types or holder types.
P - the parameter typeparamClass - the parameter classparam - the parameterDomaNullPointerException - if paramClass is nullpublic <E> UpdateBuilder params(java.lang.Class<E> elementClass, java.util.List<E> params)
The element type of the list must be one of basic types or holder types.
E - the element type of the listelementClass - the element class of the listparams - the parameter listDomaNullPointerException - if elementClass or params is nullpublic <P> UpdateBuilder literal(java.lang.Class<P> paramClass, P param)
The parameter type must be one of basic types or holder types.
P - the parameter typeparamClass - the parameter classparam - the parameterDomaNullPointerException - if paramClass is nullpublic <E> UpdateBuilder literals(java.lang.Class<E> elementClass, java.util.List<E> params)
The element type of the list must be one of basic types or holder types.
E - the element type of the listelementClass - the element class of the listparams - the parameter listDomaNullPointerException - if elementClass or params is nullpublic int execute()
UniqueConstraintException - if an unique constraint violation occursJdbcException - if a JDBC related error occurspublic void queryTimeout(int queryTimeout)
If not specified, the value of Config.getQueryTimeout() is used.
queryTimeout - the query timeout limit in secondsStatement.setQueryTimeout(int)public void callerClassName(java.lang.String className)
If not specified, the class name of this instance is used.
className - the caller class nameDomaNullPointerException - if className is nullpublic void sqlLogType(SqlLogType sqlLogType)
sqlLogType - the SQL log format typepublic void callerMethodName(java.lang.String methodName)
if not specified, execute is used.
methodName - the caller method nameDomaNullPointerException - if methodName is nullpublic Sql<?> getSql()