Ibatis 查询语句出错,看了半天没看出错误。。。。。

lx707 2012-02-28 12:06:43
public class PuterBoot
{
private String puterId;
private String goodsId;
private int optId;
/**
* @return the puterId
*/
public String getPuterId() {
return puterId;
}
/**
* @param puterId the puterId to set
*/
public void setPuterId(String puterId) {
this.puterId = puterId;
}
/**
* @return the goodsId
*/
public String getGoodsId() {
return goodsId;
}


public class PuterBootDAO

public List<?> getGoodsIdArFlagCount(PuterBoot put)
{
System.out.println("optIdMM"+put.getOptId());
System.out.println("puterIdMM"+put.getPuterId());
System.out.println("devIdMM"+put.getDevId());
return getBackOfficeSqlMapClientTemplate1().queryForList("PuterBoot.selectGoodsIdArFlagCount",put);
}
services中调用这个DAO里方法,能输出各种值
这是XML中写的SQL语句

<sqlMap namespace="PuterBoot">
<select id="selectGoodsIdArFlagCount" parameterClass="com.dingding.vms.backoffice.data.pt.PuterBoot" resultClass="java.util.HashMap">
select goods_id, ar_flag, count
from t_puter_action_detail
where opt_id = #optId#
and puter_id = #puterId#
and dev_id = #devId#
</select>
最后反回的List是空,这代码有什么问题?谢谢了
...全文
115 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
lx707 2012-02-28
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 yanmushi 的回复:]

先把你的sql在数据库运行一下。
[/Quote]
我用数值取代##后在数据库能得到值,select goods_id, ar_flag, count
from t_puter_action_detail
where opt_id =30
and puter_id = 1
and dev_id = 1
lx707 2012-02-28
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 yugaochao 的回复:]

count是关键字哦。
[/Quote]
刚才我试了,去掉and dev_id=#devId#后就能获取到很多值了,其中包括count
lx707 2012-02-28
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 chuxingzhe 的回复:]

不会报错吗 查询语句 count 不是关键字吗
[/Quote]
不抱错,直接程序异常,回滚了
艳沐石 2012-02-28
  • 打赏
  • 举报
回复
先把你的sql在数据库运行一下。
afufeng 2012-02-28
  • 打赏
  • 举报
回复
sql 返回的是一个hashmap
yugaochao 2012-02-28
  • 打赏
  • 举报
回复
count是关键字哦。
chuxingzhe 2012-02-28
  • 打赏
  • 举报
回复
不会报错吗 查询语句 count 不是关键字吗
lx707 2012-02-28
  • 打赏
  • 举报
回复
问题解决了,是数据库里面dev_id设定为char(8),我自己造的数据是1位的,00000001=1,这样就select不出东西了,谢谢大家
游一游走一走 2012-02-28
  • 打赏
  • 举报
回复
楼主请尝试在log4j配置文件中加入
log4j.logger.java.sql.Connection = DEBUG
log4j.logger.java.sql.Statement = DEBUG
log4j.logger.java.sql.PreparedStatement = DEBUG
log4j.logger.java.sql.ResultSet = DEBUG
看看ibatis实际执行的语句是什么,我感觉你的配置文件是正确的

67,512

社区成员

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

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