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 Reuben Firmin <re...@benetech.org> on 2008/04/04 03:52:41 UTC

Enum handling problem with subquery / list

Hi,

I'm having a problem handling enums from a subquery. I have a type handler
registered for the enums, but it doesn't seem to be called.

Essentially, on my result map, I have a subquery like this:

<result property="roles" column="user_account_id" select="getRoles" />

This corresponds to:

    public void setRoles(List<UserRole> roles) {
        this.roles = roles;
    }


UserRole is an enum, i.e.

public enum UserRole implements HasValue<String> {

    ADMIN("admin"),
    SPONSOR("sponsor"),
...

The getRoles statement looks like this:

<select id="getRoles" parameterClass="int" resultClass="userRoleClass">


Instead of invoking the TypeHandler on each of the results, the flow instead
goes into JavaBeansDataExchange.setData, which eventually tries to
instantiate UserRole, which fails, because it is an enum. I verified that
the TypeHandler is actually being registered in TypeHandlerFactory, but the
TypeHandler's methods are never called.

As a further test, I also set the result mapping to be:
<result property="roles" column="user_account_id" select="getRoles"
typeHandler="..."/>
This didn't result in the TypeHandler's methods being called either, which
leads me to suspect that the issue is something to do with there being a
list of results.

Any ideas on further debugging that I can do, and/or a solution? (I realize
that 2.3.1 may solve this, but I can't use it until it's non-beta.)


Thanks!
Reuben