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 "Ext_Friedrich, Stefan" <St...@sungard.de> on 2006/02/09 13:26:59 UTC
HashMap of Lists of HashMaps
Hello.
We encountered a little problem that we are not able to solve by
ourselves:
What we want to do is: Use HashMaps instead of DOM in the resultMapping.
Here's a sample of what we want to do:
<resultMap id="a" class="java.util.HashMap">
<result property="aa" select="loadAA"/>
<result property="id" column="id"/>
</resultMap>
<select id="loadA" resultMap="a">
Select id from tableA where id = 1
</select>
<resultMap id="aa" class="java.util.HashMap">
<result property="id" column="id"/>
</resultMap>
<select id="loadAA" resultMap="aa">
Select id from tableA
</select>
The first select returns one result --> a HashMap, the second select
returns numerous results --> n HashMaps that should be mapped as a List
of HashMaps.
When we implement it as a DOM and exchange the classes in the resultMaps
with the ones below, the same code works fine:
class A {
private Collection aa;
private int id;
//getters and setters
}
class AA {
private int id;
}
Is there a solution for our problem, because we want to avoid the use of
a DOM due to flexibility-reasons
Thanks
Stefan Friedrich
Re: HashMap of Lists of HashMaps
Posted by Ben Munat <be...@munat.com>.
Even better...
b
Nathan Maves wrote:
> For sure!
>
> How about POJO :)
>
> On Feb 10, 2006, at 9:44 AM, Ben Munat wrote:
>
>> Ooh, that's a very overloaded use of the acronym "DOM". Most people
>> would think "Document Object Model". You might call it a JavaBean
>> instead... heh, though that has its own perils. ;-)
>>
>> Anyway, I take it the problem is that the resultMap is working with
>> the JavaBeans (A and AA) but not with HashMap. What's the error, Stefan?
>>
>> b
>>
>> Nils Winkler wrote:
>>
>>> Domain Object Model...
>>> On Fri, 10 Feb 2006 08:06:28 -0700, "Larry Meadors"
>>> <lm...@apache.org> said:
>>>
>>>> What do you mean by DOM?
>>>>
>>>> Larry
>>>>
>>>>
>>>> On 2/9/06, Ext_Friedrich, Stefan <St...@sungard.de> wrote:
>>>>
>>>>>
>>>>> Hello.
>>>>>
>>>>> We encountered a little problem that we are not able to solve by
>>>>> ourselves:
>>>>>
>>>>> What we want to do is: Use HashMaps instead of DOM in the
>>>>> resultMapping.
>>>>> Here's a sample of what we want to do:
>>>>>
>>>>> <resultMap id="a" class="java.util.HashMap">
>>>>> <result property="aa" select="loadAA"/>
>>>>> <result property="id" column="id"/>
>>>>> </resultMap>
>>>>> <select id="loadA" resultMap="a">
>>>>> Select id from tableA where id = 1
>>>>> </select>
>>>>>
>>>>> <resultMap id="aa" class="java.util.HashMap">
>>>>> <result property="id" column="id"/>
>>>>> </resultMap>
>>>>> <select id="loadAA" resultMap="aa">
>>>>> Select id from tableA
>>>>> </select>
>>>>>
>>>>> The first select returns one result --> a HashMap, the second
>>>>> select returns
>>>>> numerous results --> n HashMaps that should be mapped as a List of
>>>>> HashMaps.
>>>>>
>>>>> When we implement it as a DOM and exchange the classes in the
>>>>> resultMaps
>>>>> with the ones below, the same code works fine:
>>>>>
>>>>> class A {
>>>>> private Collection aa;
>>>>> private int id;
>>>>> //getters and setters
>>>>> }
>>>>>
>>>>> class AA {
>>>>> private int id;
>>>>> }
>>>>>
>>>>> Is there a solution for our problem, because we want to avoid the
>>>>> use of a
>>>>> DOM due to flexibility-reasons
>>>>>
>>>>> Thanks
>>>>> Stefan Friedrich
>>>
>>> --
>>> ==================================
>>> nils@nilswinkler.com
>
>
Re: HashMap of Lists of HashMaps
Posted by Nathan Maves <Na...@Sun.COM>.
For sure!
How about POJO :)
On Feb 10, 2006, at 9:44 AM, Ben Munat wrote:
> Ooh, that's a very overloaded use of the acronym "DOM". Most people
> would think "Document Object Model". You might call it a JavaBean
> instead... heh, though that has its own perils. ;-)
>
> Anyway, I take it the problem is that the resultMap is working with
> the JavaBeans (A and AA) but not with HashMap. What's the error,
> Stefan?
>
> b
>
> Nils Winkler wrote:
>> Domain Object Model...
>> On Fri, 10 Feb 2006 08:06:28 -0700, "Larry Meadors"
>> <lm...@apache.org> said:
>>> What do you mean by DOM?
>>>
>>> Larry
>>>
>>>
>>> On 2/9/06, Ext_Friedrich, Stefan <St...@sungard.de>
>>> wrote:
>>>
>>>>
>>>> Hello.
>>>>
>>>> We encountered a little problem that we are not able to solve by
>>>> ourselves:
>>>>
>>>> What we want to do is: Use HashMaps instead of DOM in the
>>>> resultMapping.
>>>> Here's a sample of what we want to do:
>>>>
>>>> <resultMap id="a" class="java.util.HashMap">
>>>> <result property="aa" select="loadAA"/>
>>>> <result property="id" column="id"/>
>>>> </resultMap>
>>>> <select id="loadA" resultMap="a">
>>>> Select id from tableA where id = 1
>>>> </select>
>>>>
>>>> <resultMap id="aa" class="java.util.HashMap">
>>>> <result property="id" column="id"/>
>>>> </resultMap>
>>>> <select id="loadAA" resultMap="aa">
>>>> Select id from tableA
>>>> </select>
>>>>
>>>> The first select returns one result --> a HashMap, the second
>>>> select returns
>>>> numerous results --> n HashMaps that should be mapped as a List
>>>> of HashMaps.
>>>>
>>>> When we implement it as a DOM and exchange the classes in the
>>>> resultMaps
>>>> with the ones below, the same code works fine:
>>>>
>>>> class A {
>>>> private Collection aa;
>>>> private int id;
>>>> //getters and setters
>>>> }
>>>>
>>>> class AA {
>>>> private int id;
>>>> }
>>>>
>>>> Is there a solution for our problem, because we want to avoid
>>>> the use of a
>>>> DOM due to flexibility-reasons
>>>>
>>>> Thanks
>>>> Stefan Friedrich
>> --
>> ==================================
>> nils@nilswinkler.com
Re: HashMap of Lists of HashMaps
Posted by Ben Munat <be...@munat.com>.
Ooh, that's a very overloaded use of the acronym "DOM". Most people would think "Document
Object Model". You might call it a JavaBean instead... heh, though that has its own
perils. ;-)
Anyway, I take it the problem is that the resultMap is working with the JavaBeans (A and
AA) but not with HashMap. What's the error, Stefan?
b
Nils Winkler wrote:
> Domain Object Model...
>
> On Fri, 10 Feb 2006 08:06:28 -0700, "Larry Meadors"
> <lm...@apache.org> said:
>
>>What do you mean by DOM?
>>
>>Larry
>>
>>
>>On 2/9/06, Ext_Friedrich, Stefan <St...@sungard.de> wrote:
>>
>>>
>>>Hello.
>>>
>>>We encountered a little problem that we are not able to solve by ourselves:
>>>
>>>What we want to do is: Use HashMaps instead of DOM in the resultMapping.
>>>Here's a sample of what we want to do:
>>>
>>><resultMap id="a" class="java.util.HashMap">
>>> <result property="aa" select="loadAA"/>
>>> <result property="id" column="id"/>
>>></resultMap>
>>><select id="loadA" resultMap="a">
>>> Select id from tableA where id = 1
>>></select>
>>>
>>><resultMap id="aa" class="java.util.HashMap">
>>> <result property="id" column="id"/>
>>></resultMap>
>>><select id="loadAA" resultMap="aa">
>>> Select id from tableA
>>></select>
>>>
>>>The first select returns one result --> a HashMap, the second select returns
>>>numerous results --> n HashMaps that should be mapped as a List of HashMaps.
>>>
>>>When we implement it as a DOM and exchange the classes in the resultMaps
>>>with the ones below, the same code works fine:
>>>
>>>class A {
>>> private Collection aa;
>>> private int id;
>>> //getters and setters
>>>}
>>>
>>>class AA {
>>> private int id;
>>>}
>>>
>>>Is there a solution for our problem, because we want to avoid the use of a
>>>DOM due to flexibility-reasons
>>>
>>>Thanks
>>>Stefan Friedrich
>
> --
> ==================================
> nils@nilswinkler.com
>
Re: HashMap of Lists of HashMaps
Posted by Nils Winkler <ni...@nilswinkler.com>.
Domain Object Model...
On Fri, 10 Feb 2006 08:06:28 -0700, "Larry Meadors"
<lm...@apache.org> said:
> What do you mean by DOM?
>
> Larry
>
>
> On 2/9/06, Ext_Friedrich, Stefan <St...@sungard.de> wrote:
> >
> >
> > Hello.
> >
> > We encountered a little problem that we are not able to solve by ourselves:
> >
> > What we want to do is: Use HashMaps instead of DOM in the resultMapping.
> > Here's a sample of what we want to do:
> >
> > <resultMap id="a" class="java.util.HashMap">
> > <result property="aa" select="loadAA"/>
> > <result property="id" column="id"/>
> > </resultMap>
> > <select id="loadA" resultMap="a">
> > Select id from tableA where id = 1
> > </select>
> >
> > <resultMap id="aa" class="java.util.HashMap">
> > <result property="id" column="id"/>
> > </resultMap>
> > <select id="loadAA" resultMap="aa">
> > Select id from tableA
> > </select>
> >
> > The first select returns one result --> a HashMap, the second select returns
> > numerous results --> n HashMaps that should be mapped as a List of HashMaps.
> >
> > When we implement it as a DOM and exchange the classes in the resultMaps
> > with the ones below, the same code works fine:
> >
> > class A {
> > private Collection aa;
> > private int id;
> > //getters and setters
> > }
> >
> > class AA {
> > private int id;
> > }
> >
> > Is there a solution for our problem, because we want to avoid the use of a
> > DOM due to flexibility-reasons
> >
> > Thanks
> > Stefan Friedrich
--
==================================
nils@nilswinkler.com
Re: HashMap of Lists of HashMaps
Posted by Larry Meadors <lm...@apache.org>.
What do you mean by DOM?
Larry
On 2/9/06, Ext_Friedrich, Stefan <St...@sungard.de> wrote:
>
>
> Hello.
>
> We encountered a little problem that we are not able to solve by ourselves:
>
> What we want to do is: Use HashMaps instead of DOM in the resultMapping.
> Here's a sample of what we want to do:
>
> <resultMap id="a" class="java.util.HashMap">
> <result property="aa" select="loadAA"/>
> <result property="id" column="id"/>
> </resultMap>
> <select id="loadA" resultMap="a">
> Select id from tableA where id = 1
> </select>
>
> <resultMap id="aa" class="java.util.HashMap">
> <result property="id" column="id"/>
> </resultMap>
> <select id="loadAA" resultMap="aa">
> Select id from tableA
> </select>
>
> The first select returns one result --> a HashMap, the second select returns
> numerous results --> n HashMaps that should be mapped as a List of HashMaps.
>
> When we implement it as a DOM and exchange the classes in the resultMaps
> with the ones below, the same code works fine:
>
> class A {
> private Collection aa;
> private int id;
> //getters and setters
> }
>
> class AA {
> private int id;
> }
>
> Is there a solution for our problem, because we want to avoid the use of a
> DOM due to flexibility-reasons
>
> Thanks
> Stefan Friedrich