gpt4 book ai didi

java - ibatis - 如何映射值列表

转载 作者:行者123 更新时间:2023-11-30 06:48:34 26 4
gpt4 key购买 nike

我有一个 select 语句,它返回相同数据类型 (VARCHAR) 的值列表。结果介于 1 到 6 行之间。我使用 queryForList() 并将响应存储在 List 对象中。执行时出现错误

--- Cause: com.ibatis.sqlmap.client.SqlMapException: No type handler could be found to map the property 'statusList' to the column 'null'. One or both of the types, or the combination of types is not supported.

在 SQL 窗口中执行 SQL 查询时,返回 3 行。您能帮忙吗?提前致谢

<resultMap id="retrieveStatusResult"
class="ie.org.model.ResponseBO">
<result property="statusList" columnIndex="1" />
</resultMap>

<select id="retrieveStatus" parameterClass="ie.org.model.RequestBO"
resultMap="retrieveStatusResult">
SELECT (SELECT DESCRIPTION
FROM TABLEA LCD
WHERE LCD.CODE_DETAIL = QPL.STATUS)
FROM TABLEB QPL
WHERE QPL.QUOTE=#Quote#
AND VERSION IN (SELECT VERSION FROM TABLEB WHERE QUOTE = #Quote#)
</select>

ResponseBO.java

private List statusList = new ArrayList();

public List getStatusList() {
return statusList;
}

public void setStatusList(List statusList) {
this.statusList = statusList;
}

最佳答案

您没有正确映射结果/您的 bo 是错误的。

当您使用 queryForList() 时,您正在尝试创建 resultMap 中的对象列表。在您的 BO 中,您尝试从查询答案的每一行创建一个列表。

您应该使用这样的 BO:

private String status;

public String getStatus() {
return status;
}

public void setStatus(String status) {
this.status = status;
}

它具有适合您的查询答案的类型。

要使用查询结果,请像这样调用语句:

List<ResponseBO> listStatus = new ArrayList<ResponseBO>();

listStatus = (List<ResponseBO>)queryForList("retrieveStatus",properys);

propertys 是包含查询参数的 HashMap

关于java - ibatis - 如何映射值列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43258995/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com