ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Gmeiner <stefang...@gmail.com>
Subject Re: LazyLoading and CGLib problem
Date Tue, 30 Jun 2009 13:58:51 GMT
Please take a look at http://issues.apache.org/jira/browse/IBATIS-596

The Problem is that the CGLib-Proxy use the type of the property in
"myClassMap"-ResultMap instead of the result class of "permissionMap".
The patch "lazy-loading.txt" at IBATIS-596 solves this problem.



2009/6/30 Gustavo Henrique Sberze Ribas <gribas@cpqd.com.br>:
> Hi everyone,
>
>  I'm facing one big problem with lazyLoading and CGLib. In my xml, I
> have a resultMap as follows:
>
> <resultMap class="MyClass" id="myClassMap">
>    <result property="name"        column="col1"
> javaType="java.lang.String"   />
>    <result property="middleName"  column="col2"
> javaType="java.lang.String"   />
>    <result property="lastName"    column="col3"
> javaType="java.lang.String"   />
>    <result property="permissions" column="col1"
> select="myXml.getPermissions" />
> </resultMap>
>
>  In my java class "MyClass", "permissions" is an interface named
> "PermissionsIfc" (with only two methods: isInsert() and setInsert(...).
>
>  In the select statement, I have the following:
>
> <select id="getPermissions" parameterClass="java.lang.String"
> resultMap="permissionsMap">
>    SELECT
>      col5, col6, col7, col8
>    FROM
>      my_table_5
>    WHERE
>      username = #value#
> </select>
>
>  And for resultMap "permissionsMap", I have the following:
>
> <resultMap class="PermissionsClass" id="permissionsMap">
>    <result property="insert"  column="col5"
> javaType="java.lang.Boolean" />
>    <result property="update"  column="col6"
> javaType="java.lang.Boolean" />
>    <result property="delete"  column="col7"
> javaType="java.lang.Boolean" />
>    <result property="connect" column="col8"
> javaType="java.lang.Boolean" />
> </resultMap>
>
>  PermissionsClass implements PermissionsIfc, so PermissionsClass should
> be the instantiated class for property "permissions" in my first
> resultMap.
>
>  In my code, when I try to cast "permissions" to PermissionsClass, I'm
> getting a ClassCastException saying that PermissionsIfc cannot be cast
> to PermissionsClass. When LazyLoading was disabled, I wasn't getting
> this error. Is there any way to solve this?
>
> Thanks,
> Rodrigo
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Mime
View raw message