ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Slate <jsl...@mtl.mit.edu>
Subject Re: mutiple parameters in query
Date Fri, 22 Aug 2008 14:51:34 GMT
Hi jesid:

I'm not sure exactly why you want to do this, the idea is that one 
statement gives you one object. I don't even use the map stuff much b/c 
the whole point it that it is object oriented, you can easily populate 
your business objects from the DB. I suppose you could get a map of all 
the columns from both tables then go through the trouble of setting the 
values of each object from the map, but then why bother with iBATIS at all?

If, on the other hand, one of the objects is a member field of the 
other, then there are certainly ways to handle that, you'd want to look 
at the manual again for that. (One option is <result...select="..." /> 
in your resultMap element.) Hope this helps.

-Jonathan


jesid wrote:
> Hi larry, yes I read the user's guide but the problem is the follow:
>
> I need know, how can i get the result from query of two or more tables? for
> example, IPS_CARA, IPS_PERSON, this tables return to me two object
> diferents.
>
> I´m doing thus:
>
>
> Map resultMap = (HashMap) sqlMap.queryForMap("getTwoTablas",paramsMap,
> "nameKey");
>
>
> ----------
>
> <select id="getTwoTablas" resultClass="hashmap">
> SELECT 
>         *
> FROM 
> 	IPS_CARA car,
> 	IPS_PERSON per
> WHERE
> 	car.COD = per.COD and
> 	car.COD = #cod#
> </select>
>
>
> in this way the resultMap only contains 1 object, being that the query
> return more than 1 object and the key from map is null ("nameKey").
>   

Mime
View raw message