首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

MyBatis异常:Mapped Statements collection does not contain value for

2012-12-14 
MyBatis错误:Mapped Statements collection does not contain value forjava.lang.IllegalArgumentExcepti

MyBatis错误:Mapped Statements collection does not contain value for
java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for uk.co.argylesoftware.erf.framework.zmoa.persistence.FinanceDOMapper.getFinances
at org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:593)
at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:393)
at org.apache.ibatis.binding.MapperMethod.setupCommandType(MapperMethod.java:160)
at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:48)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:37)
at $Proxy75.getFinances(Unknown Source)
at uk.co.argylesoftware.erf.framework.zmoa.services.impl.FinanceServiceMgrImpl.getFinances(FinanceServiceMgrImpl.java:77)
at uk.co.argylesoftware.erf.framework.zmoa.services.impl.FinanceServiceMgrImplTest.testGetFinances(FinanceServiceMgrImplTest.java:22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:44)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)


看了网上许多解决办法 ,但是都没有解决,望高人指点
[最优解释]
从异常信息来看你Finances属性传了不正确的参数
[其他解释]
<select id="getFinances" parameterType="map" resultMap="BaseResultMap">
  <choose>
  <when test="year != null">
  select * from zmoa_finance 
  INNER JOIN zmoa_employee 
  ON zmoa_finance.EMPLOYEE_ID=zmoa_employee.EmployeeId 
  <where> 
  <if test="employee != null">
  <choose>
  <when test="moneyAmount != null">
  (MONEYAMOUNT LIKE #{moneyAmount,jdbcType=REAL}"%" 
  or EmployeeName LIKE #{employee,jdbcType="VARCHAR"}"%"
  or DESCRIBES LIKE #{describe,jdbcType="VARCHAR"}"%" ) 
  </when>
  <otherwise>
  (EmployeeName LIKE #{employee,jdbcType="VARCHAR"}"%"
  or DESCRIBES LIKE #{describe,jdbcType="VARCHAR"}"%" ) 
  </otherwise>
  </choose>
  </if>
  <if test="type != null">
  and TYPE = #{describe,jdbcType="INTEGER"} 
  </if>
  and OCCURRENCE_DATE LIKE #{year,jdbcType=INTEGER}"%" 
  </where>
  </when>
  <otherwise>
  select * from zmoa_finance 
  INNER JOIN zmoa_employee 
  ON zmoa_finance.EMPLOYEE_ID=zmoa_employee.EmployeeId 
  <where> 
  <if test="employee != null">
  <choose>
  <when test="moneyAmount != null">
  (MONEYAMOUNT LIKE #{moneyAmount,jdbcType=REAL}"%" 
  or EmployeeName LIKE #{employee,jdbcType="VARCHAR"}"%"
  or DESCRIBES LIKE #{describe,jdbcType="VARCHAR"}"%" ) 
  </when>
  <otherwise>
  (EmployeeName LIKE #{employee,jdbcType="VARCHAR"}"%"
  or DESCRIBES LIKE #{describe,jdbcType="VARCHAR"}"%" ) 
  </otherwise>
  </choose>
  </if>
  <if test="type != null">
  and TYPE = #{describe,jdbcType="INTEGER"} 
  </if>
  <if test="occurrenceDate">
  and OCCURRENCE_DATE LIKE #{occurrenceDate,jdbcType=TIMESTAMP}"%"  
  </if>
  </where>
  </otherwise>
  </choose>
  </select>
[其他解释]
没发现不正确的参数啊

[其他解释]
既然异常报这个出来。你就好好认真的比对下。
[其他解释]
这是Dao层接口
@Repository
public interface FinanceDOMapper
{
List<FinanceDO> getFinances(@Param("year")Integer year,@Param("moneyAmount")Double moneyAmount,@Param("occurrenceDate")Date occurrenceDate,


@Param("employee")String employee,@Param("type")Integer type,@Param("describe")String describe,
RowBounds rb);
}
这是Mapper.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="uk.co.argylesoftware.erf.framework.zmoa.persistence.FinanceDOMapper" >
  <resultMap id="BaseResultMap" type="uk.co.argylesoftware.erf.framework.zmoa.persistence.object.FinanceDO" >
    <id column="FINANCE_ID" property="financeId" jdbcType="BIGINT" />
    <result column="PAY" property="pay" jdbcType="REAL" />
    <result column="INCOME" property="income" jdbcType="REAL" />
    <result column="OCCURRENCE_DATE" property="occurrenceDate" jdbcType="TIMESTAMP" />
    <result column="INSERT_TIME" property="InsertTime" jdbcType="TIMESTAMP" />
    <result column="UPDATE_TIME" property="UpdateTime" jdbcType="TIMESTAMP" />
    <result column="EMPLOYEE_ID" property="employee" jdbcType="BIGINT" />
    <result column="TYPE" property="type" jdbcType="INTEGER" />
    <result column="DESCRIBES" property="describe" jdbcType="VARCHAR" />
  </resultMap>
  
  <select id="getFinances" parameterType="map" resultMap="BaseResultMap">
  <choose>
  <when test="year != null">
  select * from zmoa_finance 
  INNER JOIN zmoa_employee 
  ON zmoa_finance.EMPLOYEE_ID=zmoa_employee.EmployeeId 
  <where> 
  <if test="employee != null">
  <choose>
  <when test="moneyAmount != null">
  (MONEYAMOUNT LIKE #{moneyAmount,jdbcType=REAL}"%" 
  or EmployeeName LIKE #{employee,jdbcType="VARCHAR"}"%"
  or DESCRIBES LIKE #{describe,jdbcType="VARCHAR"}"%" ) 
  </when>
  <otherwise>
  (EmployeeName LIKE #{employee,jdbcType="VARCHAR"}"%"
  or DESCRIBES LIKE #{describe,jdbcType="VARCHAR"}"%" ) 
  </otherwise>
  </choose>
  </if>
  <if test="type != null">
  and TYPE = #{type,jdbcType="INTEGER"} 
  </if>
  and OCCURRENCE_DATE LIKE #{year,jdbcType=INTEGER}"%" 
  </where>
  </when>
  <otherwise>
  select * from zmoa_finance 
  INNER JOIN zmoa_employee 
  ON zmoa_finance.EMPLOYEE_ID=zmoa_employee.EmployeeId 
  <where> 
  <if test="employee != null">
  <choose>
  <when test="moneyAmount != null">
  (MONEYAMOUNT LIKE #{moneyAmount,jdbcType=REAL}"%" 
  or EmployeeName LIKE #{employee,jdbcType="VARCHAR"}"%"


  or DESCRIBES LIKE #{describe,jdbcType="VARCHAR"}"%" ) 
  </when>
  <otherwise>
  (EmployeeName LIKE #{employee,jdbcType="VARCHAR"}"%"
  or DESCRIBES LIKE #{describe,jdbcType="VARCHAR"}"%" ) 
  </otherwise>
  </choose>
  </if>
  <if test="type != null">
  and TYPE = #{type,jdbcType="INTEGER"} 
  </if>
  <if test="occurrenceDate">
  and OCCURRENCE_DATE LIKE #{occurrenceDate,jdbcType=TIMESTAMP}"%"  
  </if>
  </where>
  </otherwise>
  </choose>
  </select>

</mapper>
[其他解释]
网上说这种错误名称空间不匹配什么的但是不存在这个问题。参数我也对比了,上边是代码,麻烦帮我看下吧 ,本人菜鸟 ,真的很费解,困扰好久了
[其他解释]
mapper.xml文件路径和配置文件不匹配

热点排行