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 John Indra <ji...@gmail.com> on 2007/03/12 09:56:00 UTC

Object canonicalization?

Hi...

I am a very happy iBATIS user and I am still new to Java.

I have this question after reading "Pro Spring" chapter 10, "What is
missing?". From my understanding, the book says if I have 1000 rows
with a column in boolean that need to be map to Boolean object, SqlMap
will create 1000 Boolean objects whereas I will mostly need 2 Boolean
objects right?

Does the statement still hold for iBATIS 2.3.0.677?

Thanks,
John

Re: Object canonicalization?

Posted by Kris Schneider <ks...@gmail.com>.
On 3/12/07, John Indra <ji...@gmail.com> wrote:
> On 3/12/07, Gordon Ross <G....@ccw.gov.uk> wrote:
>
> Thanks for replying Gordon.
>
> > I think you are confusing objects and primitive data types.
>
> I am not. I understand object vs primitive data type in Java.
>
> > Each field/column in a row is returned as an Object (of the relevant
> > type). In this case, your field is being returned as a Boolean object,
> > with it's property set to either true or false. If your table has a
> > column of some character type, then each row would be returned with
> > individual Objects of type String.
> > Does this make sense ?
>
> Yes, and if I query the 1000 User object which has a property of type
> Boolean, with each row map to User object, I will have 1000 Boolean
> objects each attached to every User object right? I thought that in a
> perfect world, there will only be 2 Boolean object and the each 1000
> User objects will reference one of the two Boolean object.

It's easy enough to verify that there are places in the 2.3.0 codebase
that use "new Boolean(...)" instead of Boolean.TRUE or Boolean.FALSE
(or even one of the Boolean.valueOf methods).

> Please enlighten if u think I still don't get it.
>
> Thanks,
> John

-- 
Kris Schneider <ma...@gmail.com>

Re: Object canonicalization?

Posted by John Indra <ji...@gmail.com>.
On 3/12/07, Gordon Ross <G....@ccw.gov.uk> wrote:

Thanks for replying Gordon.

> I think you are confusing objects and primitive data types.

I am not. I understand object vs primitive data type in Java.

> Each field/column in a row is returned as an Object (of the relevant
> type). In this case, your field is being returned as a Boolean object,
> with it's property set to either true or false. If your table has a
> column of some character type, then each row would be returned with
> individual Objects of type String.
> Does this make sense ?

Yes, and if I query the 1000 User object which has a property of type
Boolean, with each row map to User object, I will have 1000 Boolean
objects each attached to every User object right? I thought that in a
perfect world, there will only be 2 Boolean object and the each 1000
User objects will reference one of the two Boolean object.

Please enlighten if u think I still don't get it.

Thanks,
John

Re: Object canonicalization?

Posted by Gordon Ross <G....@ccw.gov.uk>.
>>> On 12 March 2007 at 08:56, in message
<ef...@mail.gmail.com>, "John
Indra"
<ji...@gmail.com> wrote:
> Hi...
> 
> I am a very happy iBATIS user and I am still new to Java.
> 
> I have this question after reading "Pro Spring" chapter 10, "What is
> missing?". From my understanding, the book says if I have 1000 rows
> with a column in boolean that need to be map to Boolean object,
SqlMap
> will create 1000 Boolean objects whereas I will mostly need 2
Boolean
> objects right?

I don't know the book, so I could be barking up the wrong tree here
but...

I think you are confusing objects and primitive data types.

An object of type Boolean has a property with a primitive type boolean.
The type boolean can be either true or false.

Each field/column in a row is returned as an Object (of the relevant
type). In this case, your field is being returned as a Boolean object,
with it's property set to either true or false. If your table has a
column of some character type, then each row would be returned with
individual Objects of type String.

Does this make sense ?

GTG

Re: Object canonicalization?

Posted by Clinton Begin <cl...@gmail.com>.
It does hold true.

It is very easy to change, so if you submit a JIRA ticket, we'll get it in
for the next release.

I agree about priority and the performance characteristics mentioned by the
others.  But it's still a good idea and is such an easy change that it's not
worth worrying about.

Clinton

On 3/12/07, John Indra <ji...@gmail.com> wrote:
>
> Hi...
>
> I am a very happy iBATIS user and I am still new to Java.
>
> I have this question after reading "Pro Spring" chapter 10, "What is
> missing?". From my understanding, the book says if I have 1000 rows
> with a column in boolean that need to be map to Boolean object, SqlMap
> will create 1000 Boolean objects whereas I will mostly need 2 Boolean
> objects right?
>
> Does the statement still hold for iBATIS 2.3.0.677?
>
> Thanks,
> John
>