ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gareth Moorst <gazj...@yahoo.co.uk>
Subject Re: ResultMap, N+1
Date Tue, 17 Jan 2006 09:00:07 GMT
I know EXACTLY what you mean.
I'd prefer not to allow anything to have direct access to any of the Lists inside my data
objects, but iBatis has so many other good features that it was worth changing my data objects

I always use a public interface for my data objects so that I can restrict access to methods
like setSublist(List list), and then add extra methods like setThings(Thing[] things) where
I copy the array into the List. This way, the only part of the system that knows about and
uses the setList(List list) method is iBatis.

It can add a fair bit more unnecessary crap to what should be very simple objects though.

Gareth Moorst.

Perry Nguyen <pfnguyen@hanhuy.com> wrote: Gareth Moorst wrote:
> I think this is because of a different issue - when dealing with List 
> properties, I believe iBatis creates the list, sets it into the parent 
> class, then adds objects to the lists, so if you are doing any copying 
> of lists in the setAcc(List accs) method, then you will be copying an 
> empty list.
> Hope this helps,
> Gareth Moorst

I'm curious, why doesn't iBATIS do it the other way around?  Why not 
populate the list and then set the property of the bean?

For me, it's a pain because most of my N+1-type objects use arrays and 
not collections, thus I convert the input List into an array on my 
getArrayProperty getter as opposed to converting the list in 
setListProperty.  (Maybe a better answer would be for me to switch to 
Java 5 and use generics?)

To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre.
View raw message