ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Medium <contactm...@gmail.com>
Subject Re: Reusing resultmap for nested object
Date Thu, 17 Nov 2005 11:11:55 GMT
I tried this, but get the following error. I am using the java version 
2.1.6.589 (Sorry about the long trace). Hoping someone can shed some 
light on this.

Thanks.

Huy


My map is below:


<sqlMap namespace="Pick">
<resultMap id="pickResultMap" class="package.domain.Pick">
    <result column="pick_id" property="pickId"/>
    <result column="pick_ref" property="pickRef"/>
</resultMap>
<resultMap id="pickJoined" class="package.domain.Pick" 
extends="pickResultMap">
    <result property="sale" resultMap="Sale.Sale"/>
</resultMap>
</sqlMap>

<sqlMap namespace="Sale">
<typeAlias alias="Sale" type="openlink.domain.Sale"/>   
<resultMap id="Sale" class="Sale">
    <result column="sale_id" property="saleId"/>
</resultMap>
</sqlMap>

org.springframework.jdbc.UncategorizedSQLException: (SqlMapClient 
operation): encountered SQLException [ 
--- The error occurred in openlink/dao/ibatis/maps/Pick.xml. 
--- The error occurred while applying a result map. 
--- Check the Pick.pickJoined. 
--- The error happened while setting a property on the result object. 
--- Cause: com.ibatis.sqlmap.client.SqlMapException: Error instantiating 
collection property for mapping 'sale'.  Cause: java.lang.ClassCastException
Caused by: java.lang.ClassCastException]; nested exception is 
com.ibatis.common.jdbc.exception.NestedSQLException:  
--- The error occurred in openlink/dao/ibatis/maps/Pick.xml. 
--- The error occurred while applying a result map. 
--- Check the Pick.pickJoined. 
--- The error happened while setting a property on the result object. 
--- Cause: com.ibatis.sqlmap.client.SqlMapException: Error instantiating 
collection property for mapping 'sale'.  Cause: java.lang.ClassCastException
Caused by: java.lang.ClassCastException
com.ibatis.common.jdbc.exception.NestedSQLException:  
--- The error occurred in openlink/dao/ibatis/maps/Pick.xml. 
--- The error occurred while applying a result map. 
--- Check the Pick.pickJoined. 
--- The error happened while setting a property on the result object. 
--- Cause: com.ibatis.sqlmap.client.SqlMapException: Error instantiating 
collection property for mapping 'sale'.  Cause: java.lang.ClassCastException
Caused by: java.lang.ClassCastException
Caused by: com.ibatis.sqlmap.client.SqlMapException: Error instantiating 
collection property for mapping 'sale'.  Cause: java.lang.ClassCastException
Caused by: java.lang.ClassCastException
    at 
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:188)
    at 
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForObject(GeneralStatement.java:104)
    at 
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:561)
    at 
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:536)
    at 
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:93)
    at 
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientImpl.java:70)
    at 
org.springframework.orm.ibatis.SqlMapClientTemplate$1.doInSqlMapClient(SqlMapClientTemplate.java:224)
    at 
org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:165)
    at 
org.springframework.orm.ibatis.SqlMapClientTemplate.queryForObject(SqlMapClientTemplate.java:222)
    at 
openlink.domain.logic.WarehouseService.selectJoinedById(WarehouseService.java:84)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at 
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:287)
    at 
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:155)
    at 
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:122)
    at 
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:57)
    at 
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
    at 
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)
    at $Proxy0.selectJoinedById(Unknown Source)
    at 
openlink.domain.logic.WarehouseImplTest.testGetPick(WarehouseImplTest.java:55)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at junit.framework.TestCase.runTest(TestCase.java:154)
    at junit.framework.TestCase.runBare(TestCase.java:127)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:118)
    at junit.framework.TestSuite.runTest(TestSuite.java:208)
    at junit.framework.TestSuite.run(TestSuite.java:203)
    at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
    at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
    at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: com.ibatis.sqlmap.client.SqlMapException: Error instantiating 
collection property for mapping 'sale'.  Cause: java.lang.ClassCastException
Caused by: java.lang.ClassCastException
    at 
com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.setNestedResultMappingValue(BasicResultMap.java:384)
    at 
com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.applyNestedResultMap(BasicResultMap.java:356)
    at 
com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.setResultObjectValues(BasicResultMap.java:342)
    at 
com.ibatis.sqlmap.engine.mapping.statement.RowHandlerCallback.handleResultObject(RowHandlerCallback.java:63)
    at 
com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(SqlExecutor.java:391)
    at 
com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:184)
    at 
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteQuery(GeneralStatement.java:205)
    at 
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:173)
    ... 36 more
Caused by: java.lang.ClassCastException
    at 
com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.setNestedResultMappingValue(BasicResultMap.java:382)
    ... 43 more

Caused by:
com.ibatis.sqlmap.client.SqlMapException: Error instantiating collection 
property for mapping 'sale'.  Cause: java.lang.ClassCastException
Caused by: java.lang.ClassCastException
    at 
com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.setNestedResultMappingValue(BasicResultMap.java:384)
    at 
com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.applyNestedResultMap(BasicResultMap.java:356)
    at 
com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.setResultObjectValues(BasicResultMap.java:342)
    at 
com.ibatis.sqlmap.engine.mapping.statement.RowHandlerCallback.handleResultObject(RowHandlerCallback.java:63)
    at 
com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(SqlExecutor.java:391)
    at 
com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:184)
    at 
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteQuery(GeneralStatement.java:205)
    at 
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:173)
    at 
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForObject(GeneralStatement.java:104)
    at 
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:561)
    at 
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:536)
    at 
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:93)
    at 
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientImpl.java:70)
    at 
org.springframework.orm.ibatis.SqlMapClientTemplate$1.doInSqlMapClient(SqlMapClientTemplate.java:224)
    at 
org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:165)
    at 
org.springframework.orm.ibatis.SqlMapClientTemplate.queryForObject(SqlMapClientTemplate.java:222)
    at 
openlink.domain.logic.WarehouseService.selectJoinedById(WarehouseService.java:84)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at 
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:287)
    at 
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:155)
    at 
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:122)
    at 
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:57)
    at 
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
    at 
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)
    at $Proxy0.selectJoinedById(Unknown Source)
    at 
openlink.domain.logic.WarehouseImplTest.testGetPick(WarehouseImplTest.java:55)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at junit.framework.TestCase.runTest(TestCase.java:154)
    at junit.framework.TestCase.runBare(TestCase.java:127)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:118)
    at junit.framework.TestSuite.runTest(TestSuite.java:208)
    at junit.framework.TestSuite.run(TestSuite.java:203)
    at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
    at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
    at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.ClassCastException
    at 
com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.setNestedResultMappingValue(BasicResultMap.java:382)
    ... 43 more

Caused by:
java.lang.ClassCastException
    at 
com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.setNestedResultMappingValue(BasicResultMap.java:382)
    at 
com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.applyNestedResultMap(BasicResultMap.java:356)
    at 
com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.setResultObjectValues(BasicResultMap.java:342)
    at 
com.ibatis.sqlmap.engine.mapping.statement.RowHandlerCallback.handleResultObject(RowHandlerCallback.java:63)
    at 
com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(SqlExecutor.java:391)
    at 
com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:184)
    at 
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteQuery(GeneralStatement.java:205)
    at 
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:173)
    at 
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForObject(GeneralStatement.java:104)
    at 
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:561)
    at 
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:536)
    at 
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:93)
    at 
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientImpl.java:70)
    at 
org.springframework.orm.ibatis.SqlMapClientTemplate$1.doInSqlMapClient(SqlMapClientTemplate.java:224)
    at 
org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:165)
    at 
org.springframework.orm.ibatis.SqlMapClientTemplate.queryForObject(SqlMapClientTemplate.java:222)
    at 
openlink.domain.logic.WarehouseService.selectJoinedById(WarehouseService.java:84)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at 
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:287)
    at 
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:155)
    at 
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:122)
    at 
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:57)
    at 
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
    at 
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)
    at $Proxy0.selectJoinedById(Unknown Source)
    at 
openlink.domain.logic.WarehouseImplTest.testGetPick(WarehouseImplTest.java:55)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at junit.framework.TestCase.runTest(TestCase.java:154)
    at junit.framework.TestCase.runBare(TestCase.java:127)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:118)
    at junit.framework.TestSuite.runTest(TestSuite.java:208)
    at junit.framework.TestSuite.run(TestSuite.java:203)
    at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
    at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
    at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)


Gilles Bayon wrote:

> This syntax
> <resultMap id="product">
> <result property="id" column="PRD_ID"/>
> <result property="description" column="PRD_DESCRIPTION"/>
> <result property="category" resultMap="category">
> </resultMap>
>  
> is supported .
>
>  
> On 11/16/05, *Medium* <contactme42@gmail.com 
> <mailto:contactme42@gmail.com>> wrote:
>
>     Hi,
>
>     Is there a way to reuse a resultmap for a nested object ?
>
>     I know how to map it as specified by the docs but its getting a bit
>     unwieldly with all the repetition.
>
>     Docs:
>     <resultMap>
>     <result property="id" column="PRD_ID"/>
>     <result property="description" column="PRD_DESCRIPTION"/>
>     <result property="category.id" column="CAT_ID" />
>     <result property="category.description" column="CAT_DESCRIPTION" />
>     </resultMap>
>
>     Goal:
>     <resultMap id="product">
>     <result property="id" column="PRD_ID"/>
>     <result property="description" column="PRD_DESCRIPTION"/>
>     <result property="category" resultMap="category">
>     </resultMap>
>
>     <resultMap id="category">
>     <result property="id" column="CAT_ID"/>
>     <result property="description" column="CAT_DESCRIPTION"/>
>     </resultMap>
>
>     Any help would be greatly appreciated. A simple yah or nah would
>     do fine
>     as well.
>
>     Thanks
>
>     Huy
>
>


Mime
View raw message