<resultMap id="get-employee-dept" class="employee">
                 <result property="empId" column="empId" />
                 <result property="empIid" column="empIid" />
                 <result property="empName" column="empName" />
                 <result property="empAddr" column="empAddr" />
                 <result property="dept" column="deptId" select="getDeptbyDeptId"  />
     </resultMap> <select id="getEmployee" parameterClass="int" resultMap="get-employee-dept">
  select * 
    from jy_employee t1
   where t1.empId = #empId#
 </select>
 
 <select id="getDeptbyDeptId" parameterClass="int" resultClass="dept">
  select * 
    from jy_dept t
   where t.deptId = #deptId#
 </select> public static Employee empDept(int empId) {  
         SqlMapClient sqlMap = getSqlMapClient();  
         Employee dpt = null;
         try {  
             sqlMap.startTransaction();
              dpt =(Employee)sqlMap.queryForObject("User.getEmployee",empId);              sqlMap.commitTransaction();  
          } catch (SQLException e) {  
              e.printStackTrace();  
         }  
          return dpt;
     }  报错..There is no statement named getDeptbyDeptId in this SqlMap

解决方案 »

  1.   

    楼主,没懂你什么意思你代码里面是:dpt =(Employee)sqlMap.queryForObject("User.getEmployee",empId);调用的是getEmployee这个sql语句,怎么会打印:There is no statement named getDeptbyDeptId in this SqlMap你没有找准出错的地方
      

  2.   

    The error occurred in com/rong/orm/User.xml.  
    --- The error occurred while applying a result map.  
    --- Check the User.get-employee-dept.  
    --- Check the result mapping for the 'dept' property
    这个属性在EMPLOYEE里也有啊
      

  3.   

    你的dept是什么东东??有这个类吗??
      

  4.   

    <select id="getDeptbyDeptId" parameterClass="int" resultClass="dept">你没有定义一个alias   也没有dept这个类。 你如何能使用resultClass?
      

  5.   

    我这会也碰上了这个问题,不知道是怎么回事!http://topic.csdn.net/u/20110720/11/d60cfdf9-1e8f-47c9-a9d5-a9c84b7a0b2b.html?77783
      

  6.   

    我那问题解决了,不知道LZ你的问题解决了没?我是namespace配置有些问题,仔细一点就好了
      

  7.   

    最好不要用select *啊,

    select 
        数据库字段名 as java字段名