一个简单的ibatis查询问题? 请大家帮忙看看?
我的目的是返回两个表的数据的一个集合;------------------------RequisitionBillBean.xml配置文件---------------...
我的目的是返回 两个表的数据的 一个集合;
------------------------RequisitionBillBean.xml配置文件------------------------
<typeAlias alias="RequisitionBillBean" type="pack.java.jsf.javabean.RequisitionBean"/>
<typeAlias alias="User" type="com.rs.common.core.model.User"/>
<resultMap class="User" id="userMap">
<result property="firstName" column="FIRST_NAME" />
<result property="lastName" column="LAST_NAME" />
</resultMap>
<resultMap class="RequisitionBillBean" id="requisitionBillMap">
<result property="requisitionId" column="requisition_id"/>
<result property="userId" column="user_id"/>
<result property="create_date" column="create_date"/>
<result property="user" resultMap="userMap"/>
</resultMap>
---查询语句;
<select id="requisitionByQuery" parameterClass="pack.java.jsf.RequisitionBillCriteria" resultMap="requisitionBillMap">
SELECT
PL.requisition_id,
U.user_id,
PL.create_date,
U.first_name,
U.last_Name
FROM pl_requisition_bill PL
INNER JOIN PL_Users U ON(PL.user_id = U.User_id)
WHERE 1 = 1
<dynamic>
<isNotEmpty property="userId">
AND U.user_id = #userId#
</isNotEmpty>
<isNotEmpty property="firstName">
AND U.first_name like '%' #firstName# '%'
</isNotEmpty>
<isNotEmpty property="lastName">
AND U.last_name like '%' #lastName# '%'
</isNotEmpty>
</dynamic>
</select>
javaBean 如下:
public class RequisitionBillBean{
private String requisitionId;
private String userId;
private Date create_date;
private User user;
getter 和 setter省略;
}
public class User{
private String firstName;
private String lastName;
setter和setter省略..
}
--运行的时候,就报错了... 我应该怎么改啊..第一次接触ibatis. 有点生疏..
请大家帮忙看一下.. 谢谢..
严重: org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [null]; error code [0];
--- The error occurred in pack/java/jsf/javabean/RequisitionBillBean.xml.
--- The error occurred while applying a result map.
--- Check the pack.java.jsf.javabean.RequisitionBillBean.requisitionBillMap.
--- The error happened while setting a property on the result object.
--- Cause: com.ibatis.sqlmap.client.SqlMapException: There is no result map named userMap in this SqlMap.; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException: 展开
------------------------RequisitionBillBean.xml配置文件------------------------
<typeAlias alias="RequisitionBillBean" type="pack.java.jsf.javabean.RequisitionBean"/>
<typeAlias alias="User" type="com.rs.common.core.model.User"/>
<resultMap class="User" id="userMap">
<result property="firstName" column="FIRST_NAME" />
<result property="lastName" column="LAST_NAME" />
</resultMap>
<resultMap class="RequisitionBillBean" id="requisitionBillMap">
<result property="requisitionId" column="requisition_id"/>
<result property="userId" column="user_id"/>
<result property="create_date" column="create_date"/>
<result property="user" resultMap="userMap"/>
</resultMap>
---查询语句;
<select id="requisitionByQuery" parameterClass="pack.java.jsf.RequisitionBillCriteria" resultMap="requisitionBillMap">
SELECT
PL.requisition_id,
U.user_id,
PL.create_date,
U.first_name,
U.last_Name
FROM pl_requisition_bill PL
INNER JOIN PL_Users U ON(PL.user_id = U.User_id)
WHERE 1 = 1
<dynamic>
<isNotEmpty property="userId">
AND U.user_id = #userId#
</isNotEmpty>
<isNotEmpty property="firstName">
AND U.first_name like '%' #firstName# '%'
</isNotEmpty>
<isNotEmpty property="lastName">
AND U.last_name like '%' #lastName# '%'
</isNotEmpty>
</dynamic>
</select>
javaBean 如下:
public class RequisitionBillBean{
private String requisitionId;
private String userId;
private Date create_date;
private User user;
getter 和 setter省略;
}
public class User{
private String firstName;
private String lastName;
setter和setter省略..
}
--运行的时候,就报错了... 我应该怎么改啊..第一次接触ibatis. 有点生疏..
请大家帮忙看一下.. 谢谢..
严重: org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [null]; error code [0];
--- The error occurred in pack/java/jsf/javabean/RequisitionBillBean.xml.
--- The error occurred while applying a result map.
--- Check the pack.java.jsf.javabean.RequisitionBillBean.requisitionBillMap.
--- The error happened while setting a property on the result object.
--- Cause: com.ibatis.sqlmap.client.SqlMapException: There is no result map named userMap in this SqlMap.; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException: 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询