mybatis与数据库,奇怪现象,求大神解答!!

zoeybug 2013-09-02 10:27:31
小弟使用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 < 2
</select>

上面的语句,在PL/SQL中将入参配好,执行是有值的,可是返回JAVA程序后,却是空的,不懂为什么啊?
...全文
149 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
tony4geek 2013-09-02
  • 打赏
  • 举报
回复
不是很了解 parameterType="Long" , where oo2.ORDER_ITEM_ID = #{orderItemIdRepealed,jdbcType=DECIMAL} 类型不一样可以吗? 不是很懂
  • 打赏
  • 举报
回复
引用 5 楼 zoeybug 的回复:
- ==> 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),确实是传了值进去的
这个在客户端直接查询有值,用代码就不行了。那不是参数没有传进去就是数据库没值。好好查查。
zoeybug 2013-09-02
  • 打赏
  • 举报
回复
List返回空的现象是存在。但是我返回的就一个值,也是空的。太奇葩了。大伙有遇到吗?
zoeybug 2013-09-02
  • 打赏
  • 举报
回复
- ==> 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),确实是传了值进去的
zoeybug 2013-09-02
  • 打赏
  • 举报
回复
引用 3 楼 fangmingshijie 的回复:
返回的list有值吗?
不是返回List的,我这个做了限制and rownum < 2,仅有一值。而且数据库中,我造的数据,确实执行就一个值。。。
  • 打赏
  • 举报
回复
返回的list有值吗?
zoeybug 2013-09-02
  • 打赏
  • 举报
回复
引用 1 楼 fangmingshijie 的回复:
你参数没有传进去吧。debug看看,参数是否传入成功
DEBUG过了,参数确实是传进去了
  • 打赏
  • 举报
回复
你参数没有传进去吧。debug看看,参数是否传入成功
枫醉秋 2013-09-02
  • 打赏
  • 举报
回复
解决就好了,加油
zoeybug 2013-09-02
  • 打赏
  • 举报
回复
问题原因找到了: 因为上面的JAVA代码做了一个update,因此其中的status_cd已经不符合。理解错了spring的事务性。 因为spring的事务性是存在缓存的。
tony4geek 2013-09-02
  • 打赏
  • 举报
回复
哦, where oo2.ORDER_ITEM_ID ='122222222225' 这个可以查出吗?
zoeybug 2013-09-02
  • 打赏
  • 举报
回复
引用 8 楼 rui888 的回复:
不是很了解 parameterType="Long" , where oo2.ORDER_ITEM_ID = #{orderItemIdRepealed,jdbcType=DECIMAL} 类型不一样可以吗? 不是很懂
parameterType="Long" 是指定入参的JAVA类型 #{orderItemIdRepealed,jdbcType=DECIMAL} 是数据库的字段类型

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧