首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > PowerDesigner >

ibatis上insert、update、delete操作单元测试通过,发布到tomcat上执行失败

2013-09-11 
ibatis下insert、update、delete操作单元测试通过,发布到tomcat下执行失败奇怪的问题,折腾了我一上午,分析一

ibatis下insert、update、delete操作单元测试通过,发布到tomcat下执行失败
奇怪的问题,折腾了我一上午,分析一下。
ibatis下执行insert、update、delete操作,单元测试通过,发布到tomcat下执行update、delete成功,而insert时却报错,出错信息如下,分析分析。

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.dao.DataIntegrityViolationException: SqlMapClient operation; SQL [];  
--- The error occurred in com/nmgnews/fip/dao/ibatis/maps/FipInfoSort.xml. 
--- The error occurred while applying a parameter map. 
--- Check the insertInfoSort-InlineParameterMap. 
--- Check the statement (update failed). 
--- Cause: java.sql.SQLException: Duplicate entry '06' for key 1; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:  
--- The error occurred in com/nmgnews/fip/dao/ibatis/maps/FipInfoSort.xml. 
--- The error occurred while applying a parameter map. 
--- Check the insertInfoSort-InlineParameterMap. 
--- Check the statement (update failed). 
--- Cause: java.sql.SQLException: Duplicate entry '06' for key 1
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:487)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:440)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)


root cause

org.springframework.dao.DataIntegrityViolationException: SqlMapClient operation; SQL [];  
--- The error occurred in com/nmgnews/fip/dao/ibatis/maps/FipInfoSort.xml. 
--- The error occurred while applying a parameter map. 
--- Check the insertInfoSort-InlineParameterMap. 
--- Check the statement (update failed). 
--- Cause: java.sql.SQLException: Duplicate entry '06' for key 1; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:  
--- The error occurred in com/nmgnews/fip/dao/ibatis/maps/FipInfoSort.xml. 
--- The error occurred while applying a parameter map. 
--- Check the insertInfoSort-InlineParameterMap. 
--- Check the statement (update failed). 
--- Cause: java.sql.SQLException: Duplicate entry '06' for key 1
org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.translate(SQLErrorCodeSQLExceptionTranslator.java:246)
org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:196)
org.springframework.orm.ibatis.SqlMapClientTemplate.insert(SqlMapClientTemplate.java:367)
com.nmgnews.fip.dao.ibatis.SqlMapFipInfoSortDao.insertInfoSort(SqlMapFipInfoSortDao.java:30)
com.nmgnews.fip.web.spring.EditInfoSortController.handleRequest(EditInfoSortController.java:48)
org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:857)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:792)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:475)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:440)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)


root cause

com.ibatis.common.jdbc.exception.NestedSQLException:  
--- The error occurred in com/nmgnews/fip/dao/ibatis/maps/FipInfoSort.xml. 
--- The error occurred while applying a parameter map. 
--- Check the insertInfoSort-InlineParameterMap. 
--- Check the statement (update failed). 
--- Cause: java.sql.SQLException: Duplicate entry '06' for key 1
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:91)
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(SqlMapExecutorDelegate.java:447)
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert(SqlMapSessionImpl.java:82)
org.springframework.orm.ibatis.SqlMapClientTemplate$9.doInSqlMapClient(SqlMapClientTemplate.java:369)
org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:193)
org.springframework.orm.ibatis.SqlMapClientTemplate.insert(SqlMapClientTemplate.java:367)
com.nmgnews.fip.dao.ibatis.SqlMapFipInfoSortDao.insertInfoSort(SqlMapFipInfoSortDao.java:30)
com.nmgnews.fip.web.spring.EditInfoSortController.handleRequest(EditInfoSortController.java:48)
org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:857)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:792)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:475)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:440)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.

<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">

<sqlMap namespace="FipInfoSort">

  <typeAlias alias="infoSort" type="org.limojfip.domain.FipInfoSort"/>

  <select id="getInfoSort"
  parameter
  resultparameterproperty="isKey">
ISKey=#isKey#
</isNotNull>
<isNotNull prepend="," property="SName">
SName=#SName#
</isNotNull>
<isNotNull prepend="," property="description">
Description=#description#
</isNotNull>
<isNull prepend="," property="description">
Description=null
</isNull>
<isNotNull prepend="," property="parentKey">
ParentKey=#parentKey#
</isNotNull>
<isNull prepend="," property="parentKey">
ParentKey=null
</isNull>
</dynamic>
    where SKey = #SKey#
  </update>
 
  <delete id="deleteInfoSort" parameter+ action
+ "&skey=" + sKey);
return null;
}
}
}
9 楼 limogogogo 2007-09-18   由于时间问题,最终换了hibernate,没有进一步查找问题原因。我想最直接的办法是引用ibatis、spring源工程,跟踪程序的执行。 10 楼 li4li5li6 2007-09-18   人个猜测可能是你在程序中有二次调用update插入重复的数据导致的唯一性约束异常,而Junit中你的update只是调用一次测试通过,如果你调用两次update,看看有没有发生同样的异常,如果有,仔细检查代码,可能会有重复的方法调用。 11 楼 cljspn 2007-11-09   我也遇到你的问题了,我把索引删除就解决了。不是什么好办法呀,只不过是测试通通了。 12 楼 xwwccsucn 2008-07-04   cljspn 写道我也遇到你的问题了,我把索引删除就解决了。不是什么好办法呀,只不过是测试通通了。
fdafafa 13 楼 xwwccsucn 2008-07-04   cljspn 写道我也遇到你的问题了,我把索引删除就解决了。不是什么好办法呀,只不过是测试通通了。
fdafafa
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html

热点排行