Quantcast

alternative for nullValue in result tag

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

alternative for nullValue in result tag

Andreas Markitanis
Hi

I'm in the process of upgrading iBatis 2.x to myBatis 3.0.6 and I find it a bit hard to find what's exactly changed.

It's all hidden away.

So far I've found pretty decent altenatives but I haven't been able to find an alternative for the nullValue attribute in the <result ..> tag.

Anyone who has any suggestions?

Thanks
Andreas
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: alternative for nullValue in result tag

Larry Meadors
On Wed, Feb 15, 2012 at 11:24 AM, Andreas Markitanis
<[hidden email]> wrote:
> So far I've found pretty decent altenatives but I haven't been able to find an alternative for the nullValue attribute in the <result ..> tag.
>
> Anyone who has any suggestions?

That feature has been killed in 3.x.

If you want to have db null values mapped to magic numbers in your
java model, it has to be done in the SQL now.

Larry
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: alternative for nullValue in result tag

Andreas Markitanis
Thanks for your swift reply Larry.

What if we're talking about a boolean?

Would it we then either set it  0(false) or 1(true) in sql?

Thanks
Andreas
On 15 Feb 2012, at 18:27, Larry Meadors wrote:

> On Wed, Feb 15, 2012 at 11:24 AM, Andreas Markitanis
> <[hidden email]> wrote:
>> So far I've found pretty decent altenatives but I haven't been able to find an alternative for the nullValue attribute in the <result ..> tag.
>>
>> Anyone who has any suggestions?
>
> That feature has been killed in 3.x.
>
> If you want to have db null values mapped to magic numbers in your
> java model, it has to be done in the SQL now.
>
> Larry

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: alternative for nullValue in result tag

Larry Meadors
I'm guessing you'd need to do something like nvl(field, ?) - replace
the ? with your old nullValue mapping.

Larry


On Wed, Feb 15, 2012 at 11:31 AM, Andreas Markitanis
<[hidden email]> wrote:

> Thanks for your swift reply Larry.
>
> What if we're talking about a boolean?
>
> Would it we then either set it  0(false) or 1(true) in sql?
>
> Thanks
> Andreas
> On 15 Feb 2012, at 18:27, Larry Meadors wrote:
>
>> On Wed, Feb 15, 2012 at 11:24 AM, Andreas Markitanis
>> <[hidden email]> wrote:
>>> So far I've found pretty decent altenatives but I haven't been able to find an alternative for the nullValue attribute in the <result ..> tag.
>>>
>>> Anyone who has any suggestions?
>>
>> That feature has been killed in 3.x.
>>
>> If you want to have db null values mapped to magic numbers in your
>> java model, it has to be done in the SQL now.
>>
>> Larry
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: alternative for nullValue in result tag

Andreas Markitanis

But if I do this in SQL (oracle) then for a boolean type the ? would have to be set to either 0 or 1 and then mybatis takes care of the conversion to false /true accordingly. Am I wrong?

Previously for nullValue in iBatis I had false.

Thanks a lot
Andreas

On Feb 15, 2012 6:40 PM, "Larry Meadors" <[hidden email]> wrote:
I'm guessing you'd need to do something like nvl(field, ?) - replace
the ? with your old nullValue mapping.

Larry


On Wed, Feb 15, 2012 at 11:31 AM, Andreas Markitanis
<[hidden email]> wrote:
> Thanks for your swift reply Larry.
>
> What if we're talking about a boolean?
>
> Would it we then either set it  0(false) or 1(true) in sql?
>
> Thanks
> Andreas
> On 15 Feb 2012, at 18:27, Larry Meadors wrote:
>
>> On Wed, Feb 15, 2012 at 11:24 AM, Andreas Markitanis
>> <[hidden email]> wrote:
>>> So far I've found pretty decent altenatives but I haven't been able to find an alternative for the nullValue attribute in the <result ..> tag.
>>>
>>> Anyone who has any suggestions?
>>
>> That feature has been killed in 3.x.
>>
>> If you want to have db null values mapped to magic numbers in your
>> java model, it has to be done in the SQL now.
>>
>> Larry
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: alternative for nullValue in result tag

Larry Meadors
I'm not sure - write a test and verify that it does what you need.

Larry
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: alternative for nullValue in result tag

Dridi Boukelmoune
Hi,

I do not know iBatis but I think you want to use a TypeHandler to
customize your mapping (eg. boolean mapped to 0/1 or Y/N, null int
mapped to custom value...)

Dridi

http://www.zenika.com/

On Feb 15, 8:54 pm, Larry Meadors <[hidden email]> wrote:
> I'm not sure - write a test and verify that it does what you need.
>
> Larry
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: alternative for nullValue in result tag

Filipe Sousa
In reply to this post by Andreas Markitanis
I think JDBC does that conversion for you.
Loading...