ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Benedict <pbened...@apache.org>
Subject ResultMaps for collections of java.lang types (including enum)
Date Wed, 27 Dec 2006 21:55:17 GMT
I need some help, and the answer I couldn't find in the current sqlmap 
user guide.

I wrote a query which returns a user and its associated roles. The 
resultMap looks like this:

<resultMap id="userMap" class="User" groupBy="id">
   <result property="id" column="u_id" />
   <result property="roles" column="ur_id" />
</resultMap>

As you can see, I am grouping by "id" which means I should be collecting 
all my roles in property "roles" which is a List<Role>. I already have a 
type handler setup to translate the long into the enum/class, but it's 
not working yet.

While I am using Java 5, this problem is not (I don't think) a Java 5 
problem. I've seen many examples of using the @resultMap attribute on a 
collection to construct the objects to avoid N+1 selects. But what about 
just plain old Java types or enums? How do I map an inner collection of 
Long or String? I don't think it makes sense to use @resultMap because 
there are no Java bean properties to a Long or a String (and in my case 
an enum).

Thanks!!
Paul

Mime
View raw message