关闭

求解决,ibatis级联查询异常,求解决,哪里配置错了吗??(已经解决)

标签: ibatisintegerdateapacheincludenested
1431人阅读 评论(0) 收藏 举报

这是主表 xiuCentItem
<sqlMap namespace="XIU_CENT_ITEM" >
	<resultMap id="ibatorgenerated_BaseResultMap" class="com.pltfm.index.model.XiuCentItem">
		<!-- WARNING - This element is automatically generated by Apache iBATIS 
			ibator, do not modify. This element was generated on Wed Mar 21 19:47:05 
			CST 2012. -->
		<result column="CENT_ITEM_ID" property="centItemId" jdbcType="INTEGER" />
		<result column="ITEM_ID" property="itemId" jdbcType="INTEGER" />
		<result column="PARTNUMBER" property="partnumber" jdbcType="VARCHAR" />
		<result column="ITEM_NAME" property="itemName" jdbcType="VARCHAR" />
		<result column="ITEM_NAME_PRE" property="itemNamePre" jdbcType="VARCHAR" />
		<result column="ITEM_NAME_POST" property="itemNamePost"
			jdbcType="VARCHAR" />
		<result column="TAG_NAME" property="tagName" jdbcType="VARCHAR" />
		<result column="IMG_URL_TIME" property="imgUrlTime" jdbcType="VARCHAR" />
		<result column="BRAND_ID" property="brandId" jdbcType="INTEGER" />
		<result column="BRAND_NAME" property="brandName" jdbcType="VARCHAR" />
		<result column="BRAND_NAME_EN" property="brandNameEn" jdbcType="VARCHAR" />
		<result column="DESC_SHORT" property="descShort" jdbcType="VARCHAR" />
		<result column="STATE_ONSALE" property="stateOnsale" jdbcType="CHAR" />
		<result column="STATE_OFFSHOW" property="stateOffshow"
			jdbcType="CHAR" />
		<result column="ONSALE_TIME" property="onsaleTime" jdbcType="DATE" />
		<result column="FLAG_INSTMT" property="flagInstmt" jdbcType="CHAR" />
		<result column="AUTHOR" property="author" jdbcType="VARCHAR" />
		<result column="FLAG_GLOABL" property="flagGloabl" jdbcType="CHAR" />
		<result column="RMARK" property="rmark" jdbcType="VARCHAR" />
		<result column="ITEM_UPDATE_TIME" property="itemUpdateTime"
			jdbcType="DATE" />
		<result column="IMG_URL_SKU" property="imgUrlSku" jdbcType="VARCHAR" />
		<result column="DATA_STATE" property="dataState" jdbcType="CHAR" />
		<result column="CREATE_TIME" property="createTime" jdbcType="DATE" />
		<result column="UPDATE_TIME" property="updateTime" jdbcType="DATE" />
		<result column="ITEM_COLOR" property="itemColor" jdbcType="VARCHAR" />
		<result column="ITEM_SIZE" property="itemSize" jdbcType="VARCHAR" />
		<result column="ITEM_LIMIT" property="itemLimit" jdbcType="INTEGER" />
		<result column="SALE_PRE_START" property="salePreStart"
			jdbcType="DATE" />
		<result column="SALE_PRE_END" property="salePreEnd" jdbcType="DATE" />
		<result column="SALE_PRE_RECEIVE" property="salePreReceive"
			jdbcType="DATE" />
		<result column="SALE_LIMIT_START" property="saleLimitStart"
			jdbcType="DATE" />
		<result column="SALE_LIMIT_END" property="saleLimitEnd"
			jdbcType="DATE" />
		<result column="IMG_URL_VERSION" property="imgUrlVersion"
			jdbcType="VARCHAR" />
		<result column="PRODUCT_AREA" property="productArea" jdbcType="VARCHAR" />
		<result column="OFFSALE_TIME" property="offsaleTime" jdbcType="DATE" />
	</resultMap>
	<resultMap id="ibatorgenerated_DetailResultMap" extends="ibatorgenerated_BaseResultMap" class="com.pltfm.index.model.XiuCentItem">
		<!--result column="ITEM_ID" property="xiuCentPrice" jdbcType="INTEGER" resultMap="XIU_CENT_PRICE.ibatorgenerated_BaseResultMap"
               select="XIU_CENT_PRICE.ibatorgenerated_selectXiuCentPriceListByItemId"/-->
         <result column="ITEM_ID" property="xiuCentPrice"  select="XIU_CENT_PRICE.ibatorgenerated_selectXiuCentPriceListByItemId"/>
         <result column="ITEM_ID" property="xiuCentClass"  select="XIU_CENT_CLASS.ibatorgenerated_selectXiuCentClassListByItemId"/>
         <result column="ITEM_ID" property="xiuCentAttrList"  select="XIU_CENT_ATTR.ibatorgenerated_selectXiuCentAttrListByItemId"/> </resultMap>
 <select id="searchPageByVo" parameterClass="com.pltfm.index.model.XiuCentItem"
        resultMap="ibatorgenerated_DetailResultMap">
        SELECT
        <include refid="ibatorgenerated_column_name" />
        ,x_so_saletotal
        FROM (
        select
        ROW_NUMBER() OVER(order by CENT_ITEM_ID
        desc) as
        view_row_number,
        tt.* ,xspw.x_so_saletotal from
        XIU_CENT_ITEM tt
        left join x_so_productsale_week xspw on
        tt.partnumber=xspw.x_so_proceductid
        <dynamic prepend="where">
            <include refid="ibatorgenerated_select_column_where_selective" />
        </dynamic>
        ) WHERE view_row_number between #skip# and #max#
    </select>
    <!-- 手动添加 -->
</sqlMap>

这是字表

<sqlMap namespace="XIU_CENT_PRICE" >
  <resultMap id="ibatorgenerated_BaseResultMap" class="com.pltfm.index.model.XiuCentPrice" >
    <!--
      WARNING - This element is automatically generated by Apache iBATIS ibator, do not modify.
      This element was generated on Wed Mar 21 19:47:05 CST 2012.
    -->
    <result column="CENT_PRICE_ID" property="centPriceId" jdbcType="INTEGER" />
    <result column="ITEM_ID" property="itemId" jdbcType="INTEGER" />
    <result column="PARTNUMBER" property="partnumber" jdbcType="VARCHAR" />
    <result column="PRICE_XIU" property="priceXiu" jdbcType="INTEGER" />
    <result column="PRICE_MKT" property="priceMkt" jdbcType="INTEGER" />
    <result column="PRICE_ACTIVITY" property="priceActivity" jdbcType="INTEGER" />
    <result column="TYPE_ACTIVITY" property="typeActivity" jdbcType="CHAR" />
    <result column="DATA_STATE" property="dataState" jdbcType="CHAR" />
    <result column="CREATE_TIME" property="createTime" jdbcType="DATE" />
    <result column="UPDATE_TIME" property="updateTime" jdbcType="DATE" />
  </resultMap>
    <select id="ibatorgenerated_selectXiuCentPriceListByItemId" parameterClass="java.lang.Integer"  resultMap="ibatorgenerated_BaseResultMap">
    select 
        <include refid="ibatorgenerated_column_name"  />
        from XIU_CENT_PRICE
        where ITEM_ID = #value# and rownum=1
    </select>
</sqlMap>


	public class XiuCentItem implements Serializable {
    /**
     * This field was generated by Apache iBATIS ibator. This field corresponds
     * to the database column XIU_CENT_ITEM.CENT_ITEM_ID
     * 
     * @ibatorgenerated Wed Mar 21 19:47:05 CST 2012
     */
    private Integer centItemId;

    /**
     * This field was generated by Apache iBATIS ibator. This field corresponds
     * to the database column XIU_CENT_ITEM.ITEM_ID
     * 
     * @ibatorgenerated Wed Mar 21 19:47:05 CST 2012
     */
    private Integer itemId;


        private List<XiuCentAttr> xiuCentAttrList = new ArrayList<XiuCentAttr>();
	private XiuCentClass xiuCentClass;
	private XiuCentPrice xiuCentPrice;
	private XiuCentItem xiuCentItem;

虽然去掉 
resultMap="XIU_CENT_PRICE.ibatorgenerated_BaseResultMap"

不会报异常,但是取得的xiuCentPrice 对象中的属性为空

还是要去掉那个

<result column="ITEM_ID" property="xiuCentPrice" jdbcType="INTEGER" resultMap="XIU_CENT_PRICE.ibatorgenerated_BaseResultMap"  select="XIU_CENT_PRICE.ibatorgenerated_selectXiuCentPriceListByItemId"/> 中的这个

resultMap="XIU_CENT_PRICE.ibatorgenerated_BaseResultMap"


 

 <sqlMap namespace="XIU_CENT_ATTR" >
  <resultMap id="ibatorgenerated_BaseResultMap" class="com.pltfm.index.model.XiuCentAttr" >
    <!--
      WARNING - This element is automatically generated by Apache iBATIS ibator, do not modify.
      This element was generated on Wed Mar 21 19:47:05 CST 2012.
    -->
    <result column="CENT_ATTR_ID" property="centAttrId" jdbcType="INTEGER" />
    <result column="ITEM_ID" property="itemId" jdbcType="INTEGER" />
    <result column="ATTR_ID" property="attrId" jdbcType="INTEGER" />
    <result column="ATTR_NAME" property="attrName" jdbcType="VARCHAR" />
    <result column="ATTR_VALUE" property="attrValue" jdbcType="VARCHAR" />
    <result column="PARTNUMBER" property="partnumber" jdbcType="VARCHAR" />
    <result column="DATA_STATE" property="dataState" jdbcType="CHAR" />
    <result column="CREATE_TIME" property="createTime" jdbcType="DATE" />
    <result column="UPDATE_TIME" property="updateTime" jdbcType="DATE" />
  </resultMap>
<select id="ibatorgenerated_selectXiuCentAttrListByItemId" resultMap="ibatorgenerated_BaseResultMap"
		parameterClass="java.lang.Integer">
		select
		<include refid="ibatorgenerated_column_name" />
		from XIU_CENT_ATTR
		where ITEM_ID = #value#
	</select>
</sqlMap>



Cause: com.ibatis.sqlmap.client.SqlMapException: Error getting nested result map values for 'xiuCentPrice'.  Cause: java.sql.SQLException: 列名无效

    at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryWithCallback(MappedStatement.java:204)
    at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryForList(MappedStatement.java:139)
    at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:567)
    at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:541)
    at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:118)
    at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForList(SqlMapClientImpl.java:94)
    at com.pltfm.index.dao.XiuCentItemDAOImpl.selectPageByVo(XiuCentItemDAOImpl.java:190)
    at com.pltfm.index.manager.XiuCentItemManager.searchXiuCentItemDetailByVO(XiuCentItemManager.java:57)
    at com.pltfm.index.service.XiuCentItemService.searchXiuCentItemDetailByVO(XiuCentItemService.java:42)
    at com.pltm.index.service.XiuCentItemServerTest.testSearchXiuCentItemDetailByVO(XiuCentItemServerTest.java:88)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: com.ibatis.sqlmap.client.SqlMapException: Error getting nested result map values for 'xiuCentPrice'.  Cause: java.sql.SQLException: 列名无效
    at com.ibatis.sqlmap.engine.mapping.result.ResultMap.setNestedResultMappingValue(ResultMap.java:467)
    at com.ibatis.sqlmap.engine.mapping.result.ResultMap.applyNestedResultMap(ResultMap.java:395)
    at com.ibatis.sqlmap.engine.mapping.result.ResultMap.setResultObjectValues(ResultMap.java:380)
    at com.ibatis.sqlmap.engine.mapping.statement.RowHandlerCallback.handleResultObject(RowHandlerCallback.java:64)
    at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(SqlExecutor.java:385)
    at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleMultipleResults(SqlExecutor.java:300)
    at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:189)
    at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.sqlExecuteQuery(MappedStatement.java:221)
    at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryWithCallback(MappedStatement.java:189)
    ... 33 more
Caused by: java.sql.SQLException: 列名无效
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
    at oracle.jdbc.driver.OracleStatement.getColumnIndex(OracleStatement.java:3319)
    at oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:1926)
    at oracle.jdbc.driver.OracleResultSet.getInt(OracleResultSet.java:1563)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.ibatis.common.jdbc.logging.ResultSetLogProxy.invoke(ResultSetLogProxy.java:47)
    at $Proxy8.getInt(Unknown Source)
    at com.ibatis.sqlmap.engine.type.IntegerTypeHandler.getResult(IntegerTypeHandler.java:35)
    at com.ibatis.sqlmap.engine.mapping.result.ResultMap.getPrimitiveResultMappingValue(ResultMap.java:619)
    at com.ibatis.sqlmap.engine.mapping.result.ResultMap.getResults(ResultMap.java:345)
    at com.ibatis.sqlmap.engine.mapping.result.ResultMap.setNestedResultMappingValue(ResultMap.java:454)
    ... 41 more
2
1

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:75883次
    • 积分:1169
    • 等级:
    • 排名:千里之外
    • 原创:44篇
    • 转载:0篇
    • 译文:0篇
    • 评论:12条
    最新评论