Thank you Jeff,
Why is that necessary if I pass (java.lang.Integer)null?
Zsolt
From: Jeff Butler [mailto:[EMAIL PROTECTED]]
Sent: Monday, October 09, 2006 4:34 PM
To: [email protected]
Subject: Re: iBATIS with the embedded Derby JDBC driver
If a column can be null, then you need to specify the JDBC type in the mapping. For example:
<insert ...>
insert into sometable (id, desc)
values(#id:INTEGER#, #desc:VARCHAR#)
</insert>
This is true for all the DB2-like databases.
Jeff Butler
On 10/9/06, Zsolt < [EMAIL PROTECTED]> wrote:
Hi,
Our product uses the services of iBATIS and we are using MySQL for the
database layer. We recently tried out the Derby database engine and we
were mainly successful.
We have an issue though, which seems to be related to iBATIS. While
things are under control with the networked Derby JDBC driver, the
embedded Derby JDBC driver does not work and we systematically receive
the following stack trace pattern:
java.sql.SQLException: An attempt was made to get a data value of type
'VARCHAR' from a data value of type '0'.
at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate (Ge
neralStatement.java:91)
Based on discussions with the Derby team, the problem seems to appear
due to a misbehaving iBATIS call. More specifically, the
java.sql.PreparedStatement.setNull(int parameterIndex, int sqlType)
call seems to be always made with the sqlType argument being 0 instead
of the type of the parameter.
We are using iBATIS 2.1.7.597. We did not dive into the iBATIS source
code but instead thought to ask here. Is this a known issue?
Zsolt
It avoids another introspection (if the getter returns null, then iBATIS would need to look up the getter type and then translate to a JDBC type).
There has been some talk about adding support for that kind of introspection with nulls, but no one's signed up to do it - and I'm not sure it's worth the (minor) performance hit.
Of course, if the DB2 drivers didn't choke on this, it would be even better - but it's not just DB2 that has the issue.
Jeff Butler
On 10/10/06, Zsolt <[EMAIL PROTECTED]> wrote:
