You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Zsolt Koppany <zk...@intland.com> on 2008/11/19 11:15:02 UTC
ibatis & derby problem
Hi,
with all newer derby versions I get an Exception if I want to store NULL
values.
Derby (or ibatis) wants my application telling also the java type of the
NULL value something like below:
#value:INTEGER#
We cannot modify all ibatis files and additional we should write a lot
of new tests testing all possible NULL values.
We use ibatis-2.3.4.726.
How can we fix the problem?
Zsolt
com.intland.codebeamer.persistence.util.PersistenceException:
com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred while applying a parameter map.
--- Check the createUser-InlineParameterMap.
--- Check the parameter mapping for the 'hostName' property.
--- Cause: java.sql.SQLException: An attempt was made to get a data
value of type '<UNKNOWN>' from a data value of type 'VARCHAR'.
at
com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeUpdate(MappedStatement.java:107)
at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(SqlMapExecutorDelegate.java:393)
at
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert(SqlMapSessionImpl.java:82)
at
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.insert(SqlMapClientImpl.java:58)
at
com.intland.codebeamer.persistence.util.SqlMapClientWrapper.insert(SqlMapClientWrapper.java:302)
at
com.intland.codebeamer.persistence.dao.AbstractDao.create(AbstractDao.java:82)
at
com.intland.codebeamer.persistence.dao.impl.UserDaoImpl.create(UserDaoImpl.java:90)
at
com.intland.codebeamer.persistence.test.AbstractUserPersistenceTests.createAccount(AbstractUserPersistenceTests.java:42)
at
com.intland.codebeamer.persistence.test.AbstractProjectPersistenceTests.setUpBeforeClass(AbstractProjectPersistenceTests.java:102)
at
com.intland.codebeamer.test.AbstractCodeBeamerTests.onSetUp(AbstractCodeBeamerTests.java:132)
at
com.intland.codebeamer.persistence.test.AbstractPersistenceTests.onSetUp(AbstractPersistenceTests.java:467)
at
org.springframework.test.AbstractSingleSpringContextTests.setUp(AbstractSingleSpringContextTests.java:103)
at junit.framework.TestCase.runBare(TestCase.java:125)
at
org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:76)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred while applying a parameter map.
--- Check the createUser-InlineParameterMap.
--- Check the parameter mapping for the 'hostName' property.
--- Cause: java.sql.SQLException: An attempt was made to get a data
value of type '<UNKNOWN>' from a data value of type 'VARCHAR'.
... 26 more
Caused by: java.sql.SQLException: An attempt was made to get a data
value of type '<UNKNOWN>' from a data value of type 'VARCHAR'.
at
org.apache.derby.client.am.SQLExceptionFactory.getSQLException(Unknown
Source)
at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
at org.apache.derby.client.am.PreparedStatement.setNull(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
com.ibatis.common.jdbc.logging.PreparedStatementLogProxy.invoke(PreparedStatementLogProxy.java:70)
at $Proxy1.setNull(Unknown Source)
at
com.ibatis.sqlmap.engine.mapping.parameter.ParameterMap.setParameter(ParameterMap.java:172)
at
com.ibatis.sqlmap.engine.mapping.parameter.ParameterMap.setParameters(ParameterMap.java:126)
at
com.ibatis.sqlmap.engine.execution.SqlExecutor.executeUpdate(SqlExecutor.java:78)
at
com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.sqlExecuteUpdate(MappedStatement.java:216)
at
com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeUpdate(MappedStatement.java:94)
... 25 more
Caused by: org.apache.derby.client.am.SqlException: An attempt was made
to get a data value of type '<UNKNOWN>' from a data value of type 'VARCHAR'.
at
org.apache.derby.client.am.PreparedStatement$PossibleTypes.throw22005Exception(Unknown
Source)
... 37 more
Re: ibatis & derby problem
Posted by Larry Meadors <la...@gmail.com>.
On Sat, Nov 22, 2008 at 7:11 AM, Zsolt Koppany <zk...@intland.com> wrote:
> My impression is that the ibatis community is much more programmatic than
> the derby one, I feel to much policy there (ibm, sun etc.), however (it is
> also important to understand) derby gets better and better and I don't think
> it would be good for ibatis not to support (also stupid parts) derby.
>
Well, that's the rub - we DO support derby as much as any database. It
is just simply not possible for us to support it better.
In this case, we are at the mercy of the driver/vendor. :-/
Larry
Re: ibatis & derby problem
Posted by Zsolt Koppany <zk...@intland.com>.
Larry,
I completely agree! I see NO value. NULL is NULL regardless whether or
not Integer, String or whatever.
We have seen several times that classes got by Sun deprecated and they
came back.
Of course it is an option waiting for couple of years and hoping that
the standard will be changed again but is that reasonable?
My impression is that the ibatis community is much more programmatic
than the derby one, I feel to much policy there (ibm, sun etc.), however
(it is also important to understand) derby gets better and better and I
don't think it would be good for ibatis not to support (also stupid
parts) derby.
Zsolt
Larry Meadors schrieb:
> Here's my opinion on this, for what it's worth.
>
> Neither derby nor ibatis are at fault here - both are doing what is
> expected: Working within the constraints of a standard API from Sun
> (JDBC).
>
> The real issue here is that the standard API is kind of stupid in this case.
>
> The crappy part of that is this: You as the user are stuck between two
> products that are both working correctly (per the standard) but in a
> sub-optimal way (because of the standard).
>
> What I am left wondering is this: What is the value in the derby
> implementation of knowing the type of null that is being set, and what
> was the behavior before this change went in that allowed your
> application to work before?
>
> Larry
>
Re: ibatis & derby problem
Posted by Larry Meadors <la...@gmail.com>.
Here's my opinion on this, for what it's worth.
Neither derby nor ibatis are at fault here - both are doing what is
expected: Working within the constraints of a standard API from Sun
(JDBC).
The real issue here is that the standard API is kind of stupid in this case.
The crappy part of that is this: You as the user are stuck between two
products that are both working correctly (per the standard) but in a
sub-optimal way (because of the standard).
What I am left wondering is this: What is the value in the derby
implementation of knowing the type of null that is being set, and what
was the behavior before this change went in that allowed your
application to work before?
Larry
Re: ibatis & derby problem
Posted by Clinton Begin <cl...@gmail.com>.
I believe Bernt misunderstood your question and didn't fully understand the
details.
* The problem is that Derby *used* to be in non-compliant with the JDBC
spec.
* You used it while it wasn't compliant.
* When you upgraded to the new compliant driver, you got screwed.
While Derby may be compliant now (as Bernt believes based on his response),
it was not always compliant.
So now both iBATIS and Derby are compliant, and the only thing remaining out
of compliance is your app. It's unfortunate, but iBATIS can't do anything
to correct JDBC drivers that are or *were* non-compliant.
Cheers,
Clinton
On Sat, Nov 22, 2008 at 2:12 AM, Zsolt Koppany <zk...@intland.com>wrote:
> Hi,
>
> I attached the answer from the derby list.
>
> I just wonder how effective the communication is between the derby and
> ibatis communities.
>
> Would it be really so complicated to fix the problem? Discussions about
> standards are very important however the acceptance of API-s is more
> important, also for derby but also for ibatis.
>
> I think ibatis is with hibernate one of the best (for me the best) java
> database mappers. Sun and IBM are pushing derby. The performance of derby is
> today much better than it was a couple of years ago.
>
> Our persistence tests run 16 minutes with Oracle and 26 with derby (we use
> an old derby driver) and this results make derby more attractive because you
> just don't have the huge overhead of oracle (including the installation
> problems).
>
> Zsolt
>
> Here is the answer from the derby list:
>
> Bernt M. Johnsen schrieb:
> >>>>>>>>>>>>> Zsolt Koppany wrote (2008-11-21 09:42:51):
> >> Kathey,
> >>
> >> How can you always know the type of an Object? Ibatis supports also
> >> jdbc<-->java.util.Map mapping. How do you want to know for example if a
> >> value is not available in the Map which java type to use to set NULL?
> >>
> >> ps.setNull(1,java.sql.Types.VARCHAR);
> >>
> >> It might be a weakness of the JDBC specification (what I don't know) but
> >> our application runs for years with mysql-4.x, mysql-5, Postgress,
> >> Oracle-9 and Oracle-10. These are well known stable and good databases.
> >>
> >> Ibatis is very popular API and I'm suprised that derby doesn't well
> >> support this very useful and easy to use API.
> >
> > It could be turned the other way around: "I'm surprised that Ibatis
> > does not adhere to the JDBC standard".
> >
> > I think (and more with me) that what Derby does as in accordance with
> > the JDBC specification (I think it was thoroughly discussed on the
> > derby-dev list a year or two ago), and that MySQL,PostgreSQL and
> > Oracle has implemented something which might be interpreted as an
> > extension of the JDBC standard or just plain wrong.
> >
> > A tool like Ibatis should *not* utilize non-standard extensions
> > because that might cause portability problems, like you just
> > experienced.
> >
> >
>
>
> Clinton Begin schrieb:
>
>>
>> Yeah, this time you have to blame Derby... While Larry is right and this
>> is a very silly API... Derby was wrong to allow setting NULL without
>> specifying the type, and unfortunately you got caught using their
>> non-standard API.
>>
>> Funny how the "Java DB" is non-standard. :-)
>>
>> But then again, it just wouldn't be Sun if this stuff made any sense at
>> all...
>>
>> Clinton
>>
>>
>> On Wed, Nov 19, 2008 at 5:12 AM, Larry Meadors <larry.meadors@gmail.com<mailto:
>> larry.meadors@gmail.com>> wrote:
>>
>> This is not really an issue with ibatis, it's a SQLException thrown
>> back by the driver. We can't fix that, just like we can't fix it with
>> Oracle (which does the same thing).
>>
>> This has always seemed like a totally retarded thing to me - I mean,
>> come on JDBC, it's NULL. It's not like I'm trying to stuff "fred" into
>> an integer field. NULL doesn't really have a type, so why is the
>> method signature like this:
>>
>> void setNull(int parameterIndex, int sqlType); // this is from
>> PreparedStatement
>>
>> So, you'll have to pick one of these options:
>> 1) use a different driver
>> 2) look for a way to make derby allow that
>> 3) patch ibatis to provide that (if it can)
>>
>> Option #3 would make this less painful in *some* cases (only where you
>> are using beans and not maps) and you would have to make an attempt to
>> infer the SQL type based on the java type of the property being mapped
>> as reported by the bean.
>>
>> To be honest, I have never looked into doing this because it seemed
>> like more work than adding :VARCHAR to the nullables in my apps. If
>> you want to try it, please do - and attach the changed files to a JIRA
>> issue. We'll see if we can get it into the next 2.x release, and also
>> 3.x. :-D
>>
>> Larry
>>
>>
>> On Wed, Nov 19, 2008 at 3:15 AM, Zsolt Koppany
>> <zkoppanylist@intland.com <ma...@intland.com>> wrote:
>> > with all newer derby versions I get an Exception if I want to
>> store NULL
>> > values.
>> >
>> > Derby (or ibatis) wants my application telling also the java type
>> of the
>> > NULL value something like below:
>> >
>> > #value:INTEGER#
>> >
>> > We cannot modify all ibatis files and additional we should write
>> a lot of
>> > new tests testing all possible NULL values.
>> >
>> > We use ibatis-2.3.4.726.
>> >
>> > How can we fix the problem?
>> >
>>
>>
>>
Re: ibatis & derby problem
Posted by Zsolt Koppany <zk...@intland.com>.
Hi,
I attached the answer from the derby list.
I just wonder how effective the communication is between the derby and
ibatis communities.
Would it be really so complicated to fix the problem? Discussions about
standards are very important however the acceptance of API-s is more
important, also for derby but also for ibatis.
I think ibatis is with hibernate one of the best (for me the best) java
database mappers. Sun and IBM are pushing derby. The performance of
derby is today much better than it was a couple of years ago.
Our persistence tests run 16 minutes with Oracle and 26 with derby (we
use an old derby driver) and this results make derby more attractive
because you just don't have the huge overhead of oracle (including the
installation problems).
Zsolt
Here is the answer from the derby list:
Bernt M. Johnsen schrieb:
>>>>>>>>>>>>> Zsolt Koppany wrote (2008-11-21 09:42:51):
>> Kathey,
>>
>> How can you always know the type of an Object? Ibatis supports also
>> jdbc<-->java.util.Map mapping. How do you want to know for example
if a
>> value is not available in the Map which java type to use to set NULL?
>>
>> ps.setNull(1,java.sql.Types.VARCHAR);
>>
>> It might be a weakness of the JDBC specification (what I don't know)
but
>> our application runs for years with mysql-4.x, mysql-5, Postgress,
>> Oracle-9 and Oracle-10. These are well known stable and good databases.
>>
>> Ibatis is very popular API and I'm suprised that derby doesn't well
>> support this very useful and easy to use API.
>
> It could be turned the other way around: "I'm surprised that Ibatis
> does not adhere to the JDBC standard".
>
> I think (and more with me) that what Derby does as in accordance with
> the JDBC specification (I think it was thoroughly discussed on the
> derby-dev list a year or two ago), and that MySQL,PostgreSQL and
> Oracle has implemented something which might be interpreted as an
> extension of the JDBC standard or just plain wrong.
>
> A tool like Ibatis should *not* utilize non-standard extensions
> because that might cause portability problems, like you just
> experienced.
>
>
Clinton Begin schrieb:
>
> Yeah, this time you have to blame Derby... While Larry is right and this
> is a very silly API... Derby was wrong to allow setting NULL without
> specifying the type, and unfortunately you got caught using their
> non-standard API.
>
> Funny how the "Java DB" is non-standard. :-)
>
> But then again, it just wouldn't be Sun if this stuff made any sense at
> all...
>
> Clinton
>
>
> On Wed, Nov 19, 2008 at 5:12 AM, Larry Meadors <larry.meadors@gmail.com
> <ma...@gmail.com>> wrote:
>
> This is not really an issue with ibatis, it's a SQLException thrown
> back by the driver. We can't fix that, just like we can't fix it with
> Oracle (which does the same thing).
>
> This has always seemed like a totally retarded thing to me - I mean,
> come on JDBC, it's NULL. It's not like I'm trying to stuff "fred" into
> an integer field. NULL doesn't really have a type, so why is the
> method signature like this:
>
> void setNull(int parameterIndex, int sqlType); // this is from
> PreparedStatement
>
> So, you'll have to pick one of these options:
> 1) use a different driver
> 2) look for a way to make derby allow that
> 3) patch ibatis to provide that (if it can)
>
> Option #3 would make this less painful in *some* cases (only where you
> are using beans and not maps) and you would have to make an attempt to
> infer the SQL type based on the java type of the property being mapped
> as reported by the bean.
>
> To be honest, I have never looked into doing this because it seemed
> like more work than adding :VARCHAR to the nullables in my apps. If
> you want to try it, please do - and attach the changed files to a JIRA
> issue. We'll see if we can get it into the next 2.x release, and also
> 3.x. :-D
>
> Larry
>
>
> On Wed, Nov 19, 2008 at 3:15 AM, Zsolt Koppany
> <zkoppanylist@intland.com <ma...@intland.com>> wrote:
> > with all newer derby versions I get an Exception if I want to
> store NULL
> > values.
> >
> > Derby (or ibatis) wants my application telling also the java type
> of the
> > NULL value something like below:
> >
> > #value:INTEGER#
> >
> > We cannot modify all ibatis files and additional we should write
> a lot of
> > new tests testing all possible NULL values.
> >
> > We use ibatis-2.3.4.726.
> >
> > How can we fix the problem?
> >
>
>
Re: ibatis & derby problem
Posted by Clinton Begin <cl...@gmail.com>.
Yeah, this time you have to blame Derby... While Larry is right and this is
a very silly API... Derby was wrong to allow setting NULL without specifying
the type, and unfortunately you got caught using their non-standard API.
Funny how the "Java DB" is non-standard. :-)
But then again, it just wouldn't be Sun if this stuff made any sense at
all...
Clinton
On Wed, Nov 19, 2008 at 5:12 AM, Larry Meadors <la...@gmail.com>wrote:
> This is not really an issue with ibatis, it's a SQLException thrown
> back by the driver. We can't fix that, just like we can't fix it with
> Oracle (which does the same thing).
>
> This has always seemed like a totally retarded thing to me - I mean,
> come on JDBC, it's NULL. It's not like I'm trying to stuff "fred" into
> an integer field. NULL doesn't really have a type, so why is the
> method signature like this:
>
> void setNull(int parameterIndex, int sqlType); // this is from
> PreparedStatement
>
> So, you'll have to pick one of these options:
> 1) use a different driver
> 2) look for a way to make derby allow that
> 3) patch ibatis to provide that (if it can)
>
> Option #3 would make this less painful in *some* cases (only where you
> are using beans and not maps) and you would have to make an attempt to
> infer the SQL type based on the java type of the property being mapped
> as reported by the bean.
>
> To be honest, I have never looked into doing this because it seemed
> like more work than adding :VARCHAR to the nullables in my apps. If
> you want to try it, please do - and attach the changed files to a JIRA
> issue. We'll see if we can get it into the next 2.x release, and also
> 3.x. :-D
>
> Larry
>
>
> On Wed, Nov 19, 2008 at 3:15 AM, Zsolt Koppany <zk...@intland.com>
> wrote:
> > with all newer derby versions I get an Exception if I want to store NULL
> > values.
> >
> > Derby (or ibatis) wants my application telling also the java type of the
> > NULL value something like below:
> >
> > #value:INTEGER#
> >
> > We cannot modify all ibatis files and additional we should write a lot of
> > new tests testing all possible NULL values.
> >
> > We use ibatis-2.3.4.726.
> >
> > How can we fix the problem?
> >
>
Re: ibatis & derby problem
Posted by Larry Meadors <la...@gmail.com>.
This is not really an issue with ibatis, it's a SQLException thrown
back by the driver. We can't fix that, just like we can't fix it with
Oracle (which does the same thing).
This has always seemed like a totally retarded thing to me - I mean,
come on JDBC, it's NULL. It's not like I'm trying to stuff "fred" into
an integer field. NULL doesn't really have a type, so why is the
method signature like this:
void setNull(int parameterIndex, int sqlType); // this is from PreparedStatement
So, you'll have to pick one of these options:
1) use a different driver
2) look for a way to make derby allow that
3) patch ibatis to provide that (if it can)
Option #3 would make this less painful in *some* cases (only where you
are using beans and not maps) and you would have to make an attempt to
infer the SQL type based on the java type of the property being mapped
as reported by the bean.
To be honest, I have never looked into doing this because it seemed
like more work than adding :VARCHAR to the nullables in my apps. If
you want to try it, please do - and attach the changed files to a JIRA
issue. We'll see if we can get it into the next 2.x release, and also
3.x. :-D
Larry
On Wed, Nov 19, 2008 at 3:15 AM, Zsolt Koppany <zk...@intland.com> wrote:
> with all newer derby versions I get an Exception if I want to store NULL
> values.
>
> Derby (or ibatis) wants my application telling also the java type of the
> NULL value something like below:
>
> #value:INTEGER#
>
> We cannot modify all ibatis files and additional we should write a lot of
> new tests testing all possible NULL values.
>
> We use ibatis-2.3.4.726.
>
> How can we fix the problem?
>