There is some code using Ibatis 2.3, and I have a class User and a resultMap as follows:
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>
Then I have a select query that only returns the id:
<select id="getUserId" resultMap="userResultMap">
select id from Foo
</select>
Like that, Ibatis wants to fill in all the results on the resultMap and since "name" is not returned by the query it sends and error:
--- 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.
Is it possible somehow to have queries that only return part of the results on a resultMap ?
Your select query should be
You are missing "name" in your query. It's simple. Your result map has two properties but you only select only one property. It should be the same exactly. Hope it work.