Re: java.util.HashMap as resultClass

2005-02-26 Thread Admin
It's not that much space wasted. .V Pascal DeMilly wrote: Hi, I would like to retrieve a Map with whose key is the 1st column of my query and the value is the 2nd column. For example right now I do: select SKU, Description from Items However this returns a list of maps with the key being

Re: java.util.HashMap as resultClass

2005-01-24 Thread Clinton Begin
Final point: Most any POJO that I can imagine is cheaper to serialize than any typical Map implementation. This stands to reason simply based on that a serialized Map must contain both the metadata and the data...a serialized POJO (JavaBean) only needs to save the data. Cheers, Clinton On Mon,

Re: java.util.HashMap as resultClass

2005-01-24 Thread Pascal DeMilly
Here is the way I finally wrote t using iBatis resultMap >From my DAO: return Map getItemNames () { return getSqlMapClientTemplate().queryForMap("getItemNameMap", null, "key", "value"); } my SqlMap has now a resultMap: select SKU, Description from Items Comments are

Re: java.util.HashMap as resultClass

2005-01-24 Thread Pascal DeMilly
Prashanth. This is exactly what and why I am implementing it. Basically since my application would be remote to my business and DAO layer, I need to simplify the exchange. Moving the whole set of POJO just to get the ID and name doesn't seem efficient. My choice of keywords was certainly the best.

Re: java.util.HashMap as resultClass

2005-01-24 Thread Brice Ruth
For the record, this recommendation is far better than using a LabelValueBean in iBATIS SqlMaps ... I still do it, because its easy, but Clinton's suggestion is far superior :) On Mon, 24 Jan 2005 14:04:42 -0700, Clinton Begin <[EMAIL PROTECTED]> wrote: > Pascal, > > Another approach is to use a

Re: java.util.HashMap as resultClass

2005-01-24 Thread Brice Ruth
The Struts LabelValue bean is quite nice (and simple), though to use it with iBATIS, I needed to created my own implementation that extends the standard LabelValue bean, since what ships w/ Struts doesn't have a default constructor (and hence is not useable with reflection). I just extend the Label

Re: java.util.HashMap as resultClass

2005-01-24 Thread Clinton Begin
Pascal, Another approach is to use a wrapper class at your presentation layer. After all, this is a presentation layer problem, that is probably best solved in the presentation layer -- not in the persistence layer. By aliasing your columns to ID and Value, you've made a change to your persisten

Re: java.util.HashMap as resultClass

2005-01-24 Thread Prashanth Sukumaran
Hi Pascal, I think i understand what Brandon is trying to say. He is talking about using the right pattern for the kind of job you are trying to achieve. If my guess is right. Looks like you trying to do this for your dropdowns. I do it this way and i feel it is much cleaner this way. public

Re: java.util.HashMap as resultClass

2005-01-24 Thread Pascal DeMilly
Well. It seems logical to me. Why would iBatis go into great length at trying to map result in the SqlMap file then if it was not to limit the knowledge of your database to that XML file. The dependency have to stop somewhere and it seems to me the SqlMap file is the place where it should stop. The

Re: java.util.HashMap as resultClass

2005-01-24 Thread Brandon Goodin
that's a nasty pattern... but hey if you like it... it's your headache... not mine. On Mon, 24 Jan 2005 10:32:39 -0800, Pascal DeMilly <[EMAIL PROTECTED]> wrote: > Actually I solved it this way: > > in my DAO code, I use a generic, ID and Name for key/value pair. Then in > my iBatis SQLMap I use

Re: java.util.HashMap as resultClass

2005-01-24 Thread Pascal DeMilly
Actually I solved it this way: in my DAO code, I use a generic, ID and Name for key/value pair. Then in my iBatis SQLMap I used aliases to rename my columns to what my DAO expect. select SKU is ID, Description as Name from Items Now my DAO code is free again from Knowing how the tables

Re: java.util.HashMap as resultClass

2005-01-24 Thread Brandon Goodin
Why is it a problem to have a code dependency in an "implementation" class? It is suppossed to be aware of IBatis SQLMap semantics. You interface over your DAO class should hide the specifics of your implementation code within your Dao. Brandon On Mon, 24 Jan 2005 09:22:49 -0800, Pascal DeMill

Re: java.util.HashMap as resultClass

2005-01-24 Thread Pascal DeMilly
Thanks Larry, I tried it and it works. However this still leave some dependencies in my DAO code as I have to specify the column names there as in: return getSqlMapClientTemplate().queryForMap("getItemNameMap", null, "SKU", "Description"); How will you do about moving that code into the SqlMap.

Re: java.util.HashMap as resultClass

2005-01-24 Thread Larry Meadors
Try executeQueryForMap() instead. On Mon, 24 Jan 2005 08:42:25 -0800, Pascal DeMilly <[EMAIL PROTECTED]> wrote: > Hi, > > I would like to retrieve a Map with whose key is the 1st column of my > query and the value is the 2nd column. For example right now I do: > > > select SKU, Descrip

java.util.HashMap as resultClass

2005-01-24 Thread Pascal DeMilly
Hi, I would like to retrieve a Map with whose key is the 1st column of my query and the value is the 2nd column. For example right now I do: select SKU, Description from Items However this returns a list of maps with the key being the column name and the value the column value which se