blogjava's web log

blogjava's web log
...

ibatis jPetStore也会有个小错?

下载ibatis jPetStore看了一下,的确是个学习的好例子,

我运行了一下,用的是mysql,运行到把产品添加到购物车就报错:

com.ibatis.dao.client.template.SqlMapDaoTemplate.queryForObject

(SqlMapDaoTemplate.java:
162)
     
37 more
Caused by: java.sql.SQLException: Duplicate key or integrity 

constraint violation message from server: 
"Column 'ITEMID' in field 

list is ambiguous
"
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1997)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:
1167)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:
1278)
    at com.mysql.jdbc.Connection.execSQL(Connection.java:
2247)
    at com.mysql.jdbc.PreparedStatement.execute

(PreparedStatement.java:
1371)
    at 

com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery

(SqlExecutor.java:
180)
    at 

com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecut

eQuery(GeneralStatement.java:
205)
    at 

com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQu

eryWithCallback(GeneralStatement.java:
173)
     
43 more



查了半天原来是配置文件查询的地方有的小错误。


  <select id="getItem" resultClass="item" parameterClass="string" cacheModel="quantityCache">
    
select
//默认里面少了个”I“。。。。。
         I . ITEMID,
      LISTPRICE,
      UNITCOST,
      SUPPLIER 
AS supplierId,
      I.PRODUCTID 
AS "product.productId",
      NAME 
AS "product.name",
      DESCN 
AS "product.description",
      CATEGORY 
AS "product.categoryId",
      STATUS,
      ATTR1 
AS attribute1,
      ATTR2 
AS attribute2,
      ATTR3 
AS attribute3,
      ATTR4 
AS attribute4,
      ATTR5 
AS attribute5,
      QTY 
AS quantity
    
from ITEM I, INVENTORY V, PRODUCT P
    
where P.PRODUCTID = I.PRODUCTID
      
and I.ITEMID = V.ITEMID
      
and I.ITEMID = #value#
  
</select>

posted on 2006-05-22 00:42 record java and net 阅读(1102) 评论(4)  编辑  收藏

评论

# re: ibatis jPetStore也会有个小错? 2007-01-12 18:54 小武藏

数据库之间有差别,很正常  回复  更多评论   

# re: ibatis jPetStore也会有个小错? 2007-03-20 16:31 jun

还有一个问题,产品页面的productid都是空的,为什么?  回复  更多评论   

# re: ibatis jPetStore也会有个小错?[未登录] 2008-07-02 21:54 虫子

天啊,我用postgresql的时候,也遇到你的问题,果然是这个“I”
哈哈,你很细心,欢迎交流raofei@gmail.com  回复  更多评论   

# re: ibatis jPetStore也会有个小错? 2009-02-10 17:44 zzz

原来如此  回复  更多评论   


只有注册用户登录后才能发表评论。


网站导航:
 

导航

常用链接

留言簿(44)

新闻档案

2.动态语言

3.工具箱

9.文档教程

友情链接

搜索

最新评论