Parameter mapping attributes
The property attribute of the parameter map is the name of a JavaBean property or
Map entry of the parameter object passed to a mapped statement.
The name can be used more than once, depending on the number of times it is
needed in the statement.
For example, if the same property is being updated in the set clause of a SQL UPDATE
statement, and is also used as part of the key in the WHERE clause, the name can be
referenced twice in the mapped statement.
The javaType attribute is used to explicitly specify the Java property type of the
parameter to be set.
Normally this can be derived from a JavaBean property through reflection, but certain
mappings such as Map and XML mappings cannot provide the type to the framework.
In those cases, if the javaType is not set and the framework cannot otherwise deter-
mine the type, the type is assumed to be Object .
The jdbcType attribute is used to explicitly specify the database type of the parameter.
Some JDBC drivers are not able to identify the type of a column for certain operations
without explicitly telling the driver the column type. A perfect example of this is the
PreparedStatement.setNull(int parameterIndex, int sqlType) method.
This method requires the type to be specified. Some drivers will allow the type to be
implicit by simply sending Types.OTHER or Types.NULL .
However, the behavior is inconsistent and some drivers need the exact type to be
specified. For such situations, iBATIS allows the type to be specified using the jdbc-
Type attribute of the parameterMap property element.
This attribute is normally only required if the column can be set to null.
Another reason to use the type attribute is to explicitly specify date types when the
Java type may be ambiguous. For example, Java only has one Date value type
( java.util.Date ), but most SQL databases usually have at least three different
types. Because of this you might want to specify explicitly that your column type is
DATE versus DATETIME.
The jdbcType attribute can be set to any string value that matches a constant in the
JDBC Types class.
Search WWH ::