ibatis配置selectKey报错!!

cbaba 2012-07-05 11:19:57
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap>
<!-- 取别名 -->
<typeAlias alias="user" type="com.broada.coss.usermamt.entity.User"/>

<select id="findAllUser" resultClass="user">
<![CDATA[ select * from t_user ]]>
</select>
<select id="findUserById" parameterClass="int" resultClass="user">
select * from t_user where id=#id#
</select>
<insert id="insertUser" parameterClass="user">
<selectKey keyProperty="id" resultClass="int" type="pre">
<![CDATA[
SELECT STOCKIDSEQUENCE.NEXTVAL AS ID FROM DUAL
]]>
</selectKey>
<![CDATA[
insert into t_user(id,name,birthday,address,salary) values(#id#,#name#,#birthday#,#address#,#salary#)
]]>
</insert>
<update id="updateUser" parameterClass="user">
update t_user set name=#name#,birthday=#birthday#,address=#address#,salary=#salary# where id=#id#
</update>
<delete id="deleteUser" parameterClass="int">
delete from t_user where id=#id#
</delete>
</sqlMap>





报的错误是
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flowNo' defined in class path resource [test-appContext-common.xml]: Cannot create inner bean 'com.broada.itil.common.flowno.dao.ibatis.IbatisFlowNoDao#1fcf0ce' of type [com.broada.itil.common.flowno.dao.ibatis.IbatisFlowNoDao] while setting bean property 'flowNoDao'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.broada.itil.common.flowno.dao.ibatis.IbatisFlowNoDao#1fcf0ce' defined in class path resource [test-appContext-common.xml]: Cannot resolve reference to bean 'sqlMapClient' while setting bean property 'sqlMapClient'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlMapClient' defined in class path resource [test-daoContext-common.xml]: Invocation of init method failed; nested exception is com.ibatis.common.exception.NestedRuntimeException: Error occurred. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: com.ibatis.common.exception.NestedRuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: Element type "select" must be declared.
Caused by: org.xml.sax.SAXParseException: Element type "select" must be declared.
Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: Element type "select" must be declared.
Caused by: org.xml.sax.SAXParseException: Element type "select" must be declared.
Caused by: com.ibatis.common.exception.NestedRuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: Element type "select" must be declared.
Caused by: org.xml.sax.SAXParseException: Element type "select" must be declared.
Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: Element type "select" must be declared.
Caused by: org.xml.sax.SAXParseException: Element type "select" must be declared.
Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: com.ibatis.common.exception.NestedRuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: Element type "select" must be declared.
Caused by: org.xml.sax.SAXParseException: Element type "select" must be declared.
Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: Element type "select" must be declared.
Caused by: org.xml.sax.SAXParseException: Element type "select" must be declared.
Caused by: com.ibatis.common.exception.NestedRuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: Element type "select" must be declared.
Caused by: org.xml.sax.SAXParseException: Element type "select" must be declared.
Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: Element type "select" must be declared.
Caused by: org.xml.sax.SAXParseException: Element type "select" must be declared.
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'versionDao' defined in class path resource [test-daoContext-common.xml]: Unsatisfied dependency expressed through constructor argument with index 1 of type [boolean]: Ambiguous constructor argument types - did you specify the correct bean references as constructor arguments?
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'versionManager' defined in class path resource [test-daoContext-common.xml]: Unsatisfied dependency expressed through constructor argument with index 5 of type [java.lang.String]: Could not convert constructor argument value of type [org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy] to required type [java.lang.String]: Failed to convert value of type [org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy] to required type [java.lang.String]; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy] to required type [java.lang.String]: no matching editors or conversion strategy found
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'versionManager' defined in class path resource [test-daoContext-common.xml]: Unsatisfied dependency expressed through constructor argument with index 5 of type [java.lang.String]: Could not convert constructor argument value of type [org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy] to required type [java.lang.String]: Failed to convert value of type [org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy] to required type [java.lang.String]; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy] to required type [java.lang.String]: no matching editors or conversion strategy found
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'versionDao' defined in class path resource [test-daoContext-common.xml]: Unsatisfied dependency expressed through constructor argument with index 1 of type [boolean]: Ambiguous constructor argument types - did you specify the correct bean references as constructor arguments?
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'versionManager' defined in class path resource [test-daoContext-common.xml]: Unsatisfied dependency expressed through constructor argument with index 5 of type [java.lang.String]: Could not convert constructor argument value of type [org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy] to required type [java.lang.String]: Failed to convert value of type [org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy] to required type [java.lang.String]; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy] to required type [java.lang.String]: no matching editors or conversion strategy found
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'versionManager' defined in class path resource [test-daoContext-common.xml]: Unsatisfied dependency expressed through constructor argument with index 5 of type [java.lang.String]: Could not convert constructor argument value of type [org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy] to required type [java.lang.String]: Failed to convert value of type [org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy] to required type [java.lang.String]; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy] to required type [java.lang.String]: no matching editors or conversion strategy found
...全文
496 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复

<insert id="insertUser" parameterClass="user"
<![CDATA[
insert into t_user(id,name,birthday,address,salary) values( STOCKIDSEQUENCE.NEXTVAL ,#name#,#birthday#,#address#,#salary#)
]]>
</insert>

昨天研究了一下,改成这个样子就OK 了
但是还是不知道为什么。

.... 这个问题还得自己结..
cbaba 2012-07-05
  • 打赏
  • 举报
回复
如果把
<selectKey keyProperty="id" resultClass="int" type="pre">
<![CDATA[
SELECT STOCKIDSEQUENCE.NEXTVAL AS ID FROM DUAL
]]>
</selectKey>
这一句删除掉就不会报错 为什么啊 ~~!!!!!!! 菜鸟求真相

67,515

社区成员

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

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