Java Reference
In-Depth Information
As with the
insert
method, the
update
method takes two parameters: the name of
the mapped statement to execute, and the parameter object to be used in provid-
ing the values for completing the mapped statement. The returned value is the
number of rows affected by the
update
statement (when the specific
JDBC
driver
supports this).
The delete method
The
delete
method is almost identical to the
update
method, but instead of being
used to execute
update
SQL
statements, it is used to execute
delete
statements:
int delete(String id, Object parameterObject)
throws SQLException;
The same two parameters are used for
delete
as were used for the other two
methods: the name of the mapped statement to execute, and the parameter
object that will be used to complete the mapped statement. The value returned by
this method is the number of rows deleted by it.
5.1.2
Nonquery mapped statements
Table 5.1 is a subset of table 4.3 from chapter 4. There are three primary mapped
statement types commonly used to update the database, and two other top-level
configuration elements that can be used to create them.
Table 5.1
Mapped statement types for updating data (and related XML elements)
Mapped
statement type
Attributes
Child elements
Uses
More details
<insert>
id
parameterClass
parameterMap
All dynamic elements
<selectKey>
Inserting data
Section 5.2;
chapter 8
<update>
id
parameterClass
parameterMap
All dynamic elements
Updating data
Section 5.3;
chapter 8
<delete>
id
parameterClass
parameterMap
All dynamic elements
Deleting data
Section 5.3;
chapter 8
<procedure>
id
parameterClass
resultClass
parameterMap
resultMap
xmlResultName
All dynamic elements
Calling a stored procedure
Section 5.5;
chapter 8












