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 Ben Munat <be...@munat.com> on 2006/07/14 04:55:18 UTC

inserting null

I see in the user's manual how one can tell ibatis to interpret a given property value as 
meaning it should insert null into the column... like an int value of -9999 means insert null.

What I don't see, however, is how to tell ibatis that a null value for a property means 
insert a null. So, for example if I mapped someNum on my bean to the some_num column in my 
table, and the getSomeNum method returned null, I want ibatis to insert null into 
some_num. Is this even possible?

b

Re: inserting null

Posted by Ben Munat <be...@munat.com>.
Hmm, that's what I would have thought, but my co-worker was getting a null pointer when he 
tried to do that. Might this be because the property is an Integer and something is 
calling intValue on it?

He changed his getter to return -1 instead of null, and configured the sqlmap to insert 
null for that and it works. I just thought I'd ask here because I'm sure I'll have a 
situation at some point where I want the property getter to return null elsewhere.

b

Larry Meadors wrote:
> That is the default behavior.
> 
> Larry
> 
> 
> On 7/13/06, Ben Munat <be...@munat.com> wrote:
> 
>> I see in the user's manual how one can tell ibatis to interpret a 
>> given property value as
>> meaning it should insert null into the column... like an int value of 
>> -9999 means insert null.
>>
>> What I don't see, however, is how to tell ibatis that a null value for 
>> a property means
>> insert a null. So, for example if I mapped someNum on my bean to the 
>> some_num column in my
>> table, and the getSomeNum method returned null, I want ibatis to 
>> insert null into
>> some_num. Is this even possible?
>>
>> b
>>

Re: inserting null

Posted by Larry Meadors <lm...@apache.org>.
That is the default behavior.

Larry


On 7/13/06, Ben Munat <be...@munat.com> wrote:
> I see in the user's manual how one can tell ibatis to interpret a given property value as
> meaning it should insert null into the column... like an int value of -9999 means insert null.
>
> What I don't see, however, is how to tell ibatis that a null value for a property means
> insert a null. So, for example if I mapped someNum on my bean to the some_num column in my
> table, and the getSomeNum method returned null, I want ibatis to insert null into
> some_num. Is this even possible?
>
> b
>