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 Jonathan Tse <de...@tsez.net> on 2007/01/25 10:47:11 UTC
Strange behaviour when column is null
Hi all,
I experienced a very strange problem with iBatis. Everything is fine
until I add one more field named imagePath (String in java, varchar in
Mysql) to the DB and the product POJO. If the field is null in MySQL ,
iBatis result a NestedSQLException. But a similar field called
description have no problem at all when the field in DB is null. Then i
replace the null field with something, then the exception is not thrown.
Any input is appreciated.
Best regards,
Jonathan Tse
Product.java (other member omitted for simplicity)
private Long productId
private String description;
private String imagePath;
And my xml file for this pojo :
<resultMap id="productResult" class="product">
<result property="productId" column="product_id" />
<result property="description" column="description" />
<result property="imagePath" column="imagepath" />
</resultMap>
<select id="getProductListByCategory" resultMap="productResult">
<![CDATA[
select product_id, name, description, categoryid, listprice,
hot, enabled, imagepath from product where
categoryid = #value#
]]>
</select>
Re: Strange behaviour when column is null
Posted by Larry Meadors <lm...@apache.org>.
Just create a sqlmapconfig.xml, a sqlmap.xml, and a simple class that
loads up the configuration and runs a query that fails, you can zip it
all up and attach it to a JIRA issue.
You can probably even put the DDL for the table in the sqlmap.xml, too.
Larry
On 2/7/07, Jonathan Tse <de...@tsez.net> wrote:
> Hi Larry,
>
> Sure I can do it Any sample I can refer to?
>
> Best regards,
> Jonathan
>
> Larry Meadors wrote:
> > If you can create a complete test case that makes it fall over and
> > attach it to JIRA, one of us will get it fixed.
> >
> > Larry
> >
> >
> > On 2/7/07, Jonathan Tse <de...@tsez.net> wrote:
> >> Hi Albert,
> >>
> >> I eventually figure out what the problem is. And it seems that it is
> >> a bug or something...
> >>
> >> The strangest things is , if I move the position of the result tag
> >> of path above the result tag of listPrice , everything work fine!!! If
> >> I move it back, the problem persist .... No code changed. Just the
> >> position of the result tag!!!! ..........
> >>
> >> I guess it is something related to primitive double type ....
> >>
> >> Best regards,
> >> Jonathan
> >>
> >> p.s. : Supply with part of the source code if you guys want to further
> >> investigate it.
> >>
> >> The pojo actually look like this:
> >>
> >> private Long productId;
> >> private Long categoryId;
> >> private String name;
> >> private String description;
> >> private String productCode;
> >> private double listPrice;
> >> private int quantity;
> >> private String path;
> >> private boolean hot;
> >> private int status;
> >>
> >> And the resultMap
> >>
> >> <resultMap id="productResult" class="product">
> >> <result property="productId" column="product_id" />
> >> <result property="name" column="name" />
> >> <result property="description" column="description" />
> >> <result property="path" column="imagepath" />
> >> <result property="categoryId" column="categoryid" />
> >> <result property="listPrice" column="listprice" />
> >>
> >> <result property="hot" column="hot" />
> >> <result property="status" column="status" />
> >> </resultMap>
> >>
> >>
> >>
> >> Albert Aymerich wrote:
> >> > Just try defining the column jdbc type in the resultMap for each
> >> column that can
> >> > be nullable.
> >> > Hope this can help.
> >> >
> >> > Albert
> >> >
> >> >
> >> >
> >> >
> >>
> >>
>
>
Re: Strange behaviour when column is null
Posted by Jonathan Tse <de...@tsez.net>.
Hi Larry,
Sure I can do it Any sample I can refer to?
Best regards,
Jonathan
Larry Meadors wrote:
> If you can create a complete test case that makes it fall over and
> attach it to JIRA, one of us will get it fixed.
>
> Larry
>
>
> On 2/7/07, Jonathan Tse <de...@tsez.net> wrote:
>> Hi Albert,
>>
>> I eventually figure out what the problem is. And it seems that it is
>> a bug or something...
>>
>> The strangest things is , if I move the position of the result tag
>> of path above the result tag of listPrice , everything work fine!!! If
>> I move it back, the problem persist .... No code changed. Just the
>> position of the result tag!!!! ..........
>>
>> I guess it is something related to primitive double type ....
>>
>> Best regards,
>> Jonathan
>>
>> p.s. : Supply with part of the source code if you guys want to further
>> investigate it.
>>
>> The pojo actually look like this:
>>
>> private Long productId;
>> private Long categoryId;
>> private String name;
>> private String description;
>> private String productCode;
>> private double listPrice;
>> private int quantity;
>> private String path;
>> private boolean hot;
>> private int status;
>>
>> And the resultMap
>>
>> <resultMap id="productResult" class="product">
>> <result property="productId" column="product_id" />
>> <result property="name" column="name" />
>> <result property="description" column="description" />
>> <result property="path" column="imagepath" />
>> <result property="categoryId" column="categoryid" />
>> <result property="listPrice" column="listprice" />
>>
>> <result property="hot" column="hot" />
>> <result property="status" column="status" />
>> </resultMap>
>>
>>
>>
>> Albert Aymerich wrote:
>> > Just try defining the column jdbc type in the resultMap for each
>> column that can
>> > be nullable.
>> > Hope this can help.
>> >
>> > Albert
>> >
>> >
>> >
>> >
>>
>>
Re: Strange behaviour when column is null
Posted by Larry Meadors <lm...@apache.org>.
If you can create a complete test case that makes it fall over and
attach it to JIRA, one of us will get it fixed.
Larry
On 2/7/07, Jonathan Tse <de...@tsez.net> wrote:
> Hi Albert,
>
> I eventually figure out what the problem is. And it seems that it is
> a bug or something...
>
> The strangest things is , if I move the position of the result tag
> of path above the result tag of listPrice , everything work fine!!! If
> I move it back, the problem persist .... No code changed. Just the
> position of the result tag!!!! ..........
>
> I guess it is something related to primitive double type ....
>
> Best regards,
> Jonathan
>
> p.s. : Supply with part of the source code if you guys want to further
> investigate it.
>
> The pojo actually look like this:
>
> private Long productId;
> private Long categoryId;
> private String name;
> private String description;
> private String productCode;
> private double listPrice;
> private int quantity;
> private String path;
> private boolean hot;
> private int status;
>
> And the resultMap
>
> <resultMap id="productResult" class="product">
> <result property="productId" column="product_id" />
> <result property="name" column="name" />
> <result property="description" column="description" />
> <result property="path" column="imagepath" />
> <result property="categoryId" column="categoryid" />
> <result property="listPrice" column="listprice" />
>
> <result property="hot" column="hot" />
> <result property="status" column="status" />
> </resultMap>
>
>
>
> Albert Aymerich wrote:
> > Just try defining the column jdbc type in the resultMap for each column that can
> > be nullable.
> > Hope this can help.
> >
> > Albert
> >
> >
> >
> >
>
>
Re: Strange behaviour when column is null
Posted by Jonathan Tse <de...@tsez.net>.
Hi Albert,
I eventually figure out what the problem is. And it seems that it is
a bug or something...
The strangest things is , if I move the position of the result tag
of path above the result tag of listPrice , everything work fine!!! If
I move it back, the problem persist .... No code changed. Just the
position of the result tag!!!! ..........
I guess it is something related to primitive double type ....
Best regards,
Jonathan
p.s. : Supply with part of the source code if you guys want to further
investigate it.
The pojo actually look like this:
private Long productId;
private Long categoryId;
private String name;
private String description;
private String productCode;
private double listPrice;
private int quantity;
private String path;
private boolean hot;
private int status;
And the resultMap
<resultMap id="productResult" class="product">
<result property="productId" column="product_id" />
<result property="name" column="name" />
<result property="description" column="description" />
<result property="path" column="imagepath" />
<result property="categoryId" column="categoryid" />
<result property="listPrice" column="listprice" />
<result property="hot" column="hot" />
<result property="status" column="status" />
</resultMap>
Albert Aymerich wrote:
> Just try defining the column jdbc type in the resultMap for each column that can
> be nullable.
> Hope this can help.
>
> Albert
>
>
>
>
Re: Strange behaviour when column is null
Posted by Albert Aymerich <al...@gmail.com>.
Just try defining the column jdbc type in the resultMap for each column that can
be nullable.
Hope this can help.
Albert
RE: Strange behaviour when column is null
Posted by Randy Layman <Ra...@vocalocity.com>.
Could you include the SQL Exception that you are receiving?
Randy
-----Original Message-----
From: Jonathan Tse [mailto:dev@tsez.net]
Sent: Thursday, January 25, 2007 4:47 AM
To: user-java@ibatis.apache.org
Subject: Strange behaviour when column is null
Hi all,
I experienced a very strange problem with iBatis. Everything is fine
until I add one more field named imagePath (String in java, varchar in
Mysql) to the DB and the product POJO. If the field is null in MySQL ,
iBatis result a NestedSQLException. But a similar field called
description have no problem at all when the field in DB is null. Then i
replace the null field with something, then the exception is not thrown.
Any input is appreciated.
Best regards,
Jonathan Tse
Product.java (other member omitted for simplicity)
private Long productId
private String description;
private String imagePath;
And my xml file for this pojo :
<resultMap id="productResult" class="product">
<result property="productId" column="product_id" />
<result property="description" column="description" />
<result property="imagePath" column="imagepath" />
</resultMap>
<select id="getProductListByCategory" resultMap="productResult">
<![CDATA[
select product_id, name, description, categoryid, listprice,
hot, enabled, imagepath from product where
categoryid = #value#
]]>
</select>