ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Fereira <ja...@cornell.edu>
Subject Re: ArrayList as parameter
Date Sun, 27 Mar 2005 14:12:49 GMT
At 09:12 AM 3/19/2005 -0700, Clinton Begin wrote:
>This is an inappropriate use of a list.  A list is good for objects of
>the same (or at least similar!) type.  In your case the list contains
>completely different data.
>You should use a Map for this, or better yet, a JavaBean.

One might wonder when it's better to use a Map or a JavaBean.  I've found 
that I want to use a Map when I want to pass a parameter that I might not 
want to put in a bean I'm using.  For example, I might have a patrons bean 
with several fields (patronsid, firstname, lastname, emailaddress).  When I 
query the database for a single row using the bean for the parameter object 
works fine.  However, I might want a list of all patrons which have a 
specified string in the email address and I want the list sorted by 
lastname or emailaddress.  Since the bean doesn't have a sort order field I 
would use a Map for the parameter  object so that I could use an "ORDER BY 
#sortorder# " in the map.
John Fereira
Ithaca, NY

View raw message