java.lang.Object
org.seasar.doma.jdbc.builder.UpdateBuilder
A builder for an SQL UPDATE statement.
This is not thread safe.
Java
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();
built SQL
update Emp set name = 'SMIHT', salary = 1000 where id = 10
-
Method Summary
Modifier and TypeMethodDescriptionvoidcallerClassName(String className) Sets the caller class name.voidcallerMethodName(String methodName) Sets the caller method name.intexecute()Executes an SQL UPDATE statement.Sql<?>getSql()Returns the built SQL.<P> UpdateBuilderAppends a parameter as literal.<E> UpdateBuilderAppends a parameter list as literal.static UpdateBuildernewInstance(Config config) Creates a new instance.<P> UpdateBuilderAppends a parameter.<E> UpdateBuilderAppends a parameter list.voidqueryTimeout(int queryTimeout) Sets the query timeout limit in seconds.Removes the last SQL fragment or parameter.Appends an SQL fragment.voidsqlLogType(SqlLogType sqlLogType) Sets the SQL log format.
-
Method Details
-
newInstance
Creates a new instance.- Parameters:
config- the configuration- Returns:
- a builder
- Throws:
DomaNullPointerException- ifconfigisnull
-
sql
Appends an SQL fragment.- Parameters:
sql- the SQL fragment- Returns:
- a builder
- Throws:
DomaNullPointerException- ifsqlisnull
-
removeLast
Removes the last SQL fragment or parameter.- Returns:
- a builder
-
param
Appends a parameter.The parameter type must be one of basic types or holder types.
- Type Parameters:
P- the parameter type- Parameters:
paramClass- the parameter classparam- the parameter- Returns:
- a builder
- Throws:
DomaNullPointerException- ifparamClassisnull
-
params
Appends a parameter list.The element type of the list must be one of basic types or holder types.
- Type Parameters:
E- the element type of the list- Parameters:
elementClass- the element class of the listparams- the parameter list- Returns:
- a builder
- Throws:
DomaNullPointerException- ifelementClassorparamsisnull
-
literal
Appends a parameter as literal.The parameter type must be one of basic types or holder types.
- Type Parameters:
P- the parameter type- Parameters:
paramClass- the parameter classparam- the parameter- Returns:
- a builder
- Throws:
DomaNullPointerException- ifparamClassisnull
-
literals
Appends a parameter list as literal.The element type of the list must be one of basic types or holder types.
- Type Parameters:
E- the element type of the list- Parameters:
elementClass- the element class of the listparams- the parameter list- Returns:
- a builder
- Throws:
DomaNullPointerException- ifelementClassorparamsisnull
-
execute
public int execute()Executes an SQL UPDATE statement.- Returns:
- the affected rows count
- Throws:
UniqueConstraintException- if an unique constraint violation occursJdbcException- if a JDBC related error occurs
-
queryTimeout
public void queryTimeout(int queryTimeout) Sets the query timeout limit in seconds.If not specified, the value of
Config.getQueryTimeout()is used.- Parameters:
queryTimeout- the query timeout limit in seconds- See Also:
-
callerClassName
Sets the caller class name.If not specified, the class name of this instance is used.
- Parameters:
className- the caller class name- Throws:
DomaNullPointerException- ifclassNameisnull
-
sqlLogType
Sets the SQL log format.- Parameters:
sqlLogType- the SQL log format type
-
callerMethodName
Sets the caller method name.if not specified,
executeis used.- Parameters:
methodName- the caller method name- Throws:
DomaNullPointerException- ifmethodNameisnull
-
getSql
Returns the built SQL.- Returns:
- the built SQL
-