小弟使用Mybatis从数据库中取值。问题是:数据库中明明有值,取出来装配时,却是空的,何解???具体Mabatis的SQL写法是:
<select id="queryRelaTransitionBoDel" parameterType="Long" resultType="Long">
select  bo1.ORDER_ITEM_ID BO_ID
          from ORDER_ITEM  bo1,
               oo_rela     oor,
               order_item  oo2
         where oo2.ORDER_ITEM_ID = #{orderItemIdRepealed,jdbcType=DECIMAL}
           and oo2.state ='ADD'
           and bo1.order_item_obj_inst_id = oo2.order_item_obj_inst_id
           and bo1.state = 'DEL'
           and bo1.status_cd not in ('301200','400001','401700','101104')
           and oo2.status_cd not in ('301200','400001','401700','101104')
           and bo1.ORDER_ITEM_ID = oor.ORDER_ITEM_ID
           and bo1.order_item_obj_inst_id = oor.PROD_OFFER_INST_ID
           and oor.state = 'DEL'
           and oor.rela_type_cd = 100004
           and not exists
         (select 1
                  from atom_action a1
                 where a1.atom_action_id = oor.atom_action_id
                   and a1.status_cd ='101104')
           and rownum &lt; 2
</select>上面的语句,在PL/SQL中将入参配好,执行是有值的,可是返回JAVA程序后,却是空的,不懂为什么啊?mybatis数据库JAVA

解决方案 »

  1.   

    你参数没有传进去吧。debug看看,参数是否传入成功
      

  2.   


    DEBUG过了,参数确实是传进去了
      

  3.   


    不是返回List的,我这个做了限制and rownum &lt; 2,仅有一值。而且数据库中,我造的数据,确实执行就一个值
      

  4.   

    - ==>  Executing: select bo1.ORDER_ITEM_ID BO_ID from ORDER_ITEM bo1, oo_rela oor, order_item oo2 where oo2.ORDER_ITEM_ID = ? and oo2.state ='ADD' and bo1.order_item_obj_inst_id = oo2.order_item_obj_inst_id and bo1.state = 'DEL' and bo1.status_cd not in ('301200','400001','401700','101104') and oo2.status_cd not in ('301200','400001','401700','101104') and bo1.ORDER_ITEM_ID = oor.ORDER_ITEM_ID and bo1.order_item_obj_inst_id = oor.PROD_OFFER_INST_ID and oor.state = 'DEL' and oor.rela_type_cd = 100004 and not exists (select 1 from atom_action a1 where a1.atom_action_id = oor.atom_action_id and a1.status_cd ='101104') and rownum < 2 
    2013-09-02 10:35:00.744 [http-8001-1] DEBUG java.sql.PreparedStatement [28] - 
    ==> Parameters: 122222222225(Long)以上是DEBUG信息,可以看到==> Parameters: 122222222225(Long),确实是传了值进去的
      

  5.   

    List返回空的现象是存在。但是我返回的就一个值,也是空的。太奇葩了。大伙有遇到吗?
      

  6.   

    不是很了解   parameterType="Long" ,    where oo2.ORDER_ITEM_ID = #{orderItemIdRepealed,jdbcType=DECIMAL} 类型不一样可以吗? 不是很懂
      

  7.   


     parameterType="Long" 是指定入参的JAVA类型
     #{orderItemIdRepealed,jdbcType=DECIMAL} 是数据库的字段类型
      

  8.   

    哦,  where oo2.ORDER_ITEM_ID ='122222222225' 这个可以查出吗?
      

  9.   

    问题原因找到了:
        因为上面的JAVA代码做了一个update,因此其中的status_cd已经不符合。理解错了spring的事务性。
    因为spring的事务性是存在缓存的。