Return types for update methods in the Data interface

This table shows the return types for each update method in the Data interface.
Table 1. Key to the table of return types
Abbreviation Meaning
O Object
T generic class, which can be a wrapper class for a primitive Java™ type, a simple Object type, or a bean
Table 2. Return types for each update method in the Data interface
  Return types
update method int int[] O[] <T>
update() X      
update() with returnClass     X X
updateMany()   X    

The update() method returns an integer that indicates the update count for the SQL statement. The updateMany() method returns an array of integers, each integer indicating the update count for a single run of the SQL statement.

The update() method that takes a returnClass as a parameter is used to request information about auto-generated keys. When the returnClass is an Object[], that array contains both the auto-generated key values and an update count. When the returnClass is not an Object[], this method returns an instance of returnClass that contains the first or only auto-generated key, and the update count is discarded.

Restriction for returning <T> objects

When you use a method of the Data interface, do not specify a generic <T> class that is any of the <primitive Java type>.class classes, such as int.class.

Information regarding SQL null values is lost whenever information queried from SQL is stored in a primitive Java type. Also, Java requires that a generic method that specifies generic <T> class of a <primitive Java type>.class must return an instance of the wrapper class that is appropriate for that primitive Java type.

For example, Java does not allow method invocations such as this:
int tCount = data.queryFirst("select ...", int.class, p);
because the definition of the queryFirst() method is this:
<T> T data.queryFirst(String sql, Class<T> returnType, Object... params);
The declared class of tCount must be Integer.
Integer tCount = data.queryFirst("select ...", Integer.class, p);

Feedback