有一些使用 Ibatis 2.3 的代码,我有一个类 User 和一个 resultMap 如下:
public class User {
private Integer id;
private String name;
public Integer getId() {
return this.id;
}
public void setId(final Integer id) {
this.id = id;
}
public String getName() {
return this.name;
}
public void setName(final String name) {
this.name = name;
}
}
<resultMap id="userResultMap" class="user">
<result property="id" column="id"/>
<result property="name" column="name"/>
</resultMap>
然后我有一个只返回 id 的选择查询:
<select id="getUserId" resultMap="userResultMap">
select id from Foo
</select>
像这样,Ibatis 想要在 resultMap 上填写所有结果,并且由于它发送的查询没有返回“name”并且错误:
--- The error occurred in ibatis/user.xml.
--- The error occurred while applying a result map.
--- Check the user.userResultMap.
--- Check the result mapping for the 'name' property.
--- Cause: java.sql.SQLException: Column 'name' not found.
是否有可能以某种方式只返回 resultMap 上的部分结果的查询?