dポイントプレゼントキャンペーン実施中!

SqlMap.xmlにて
</select>
<select id="getDept" resultClass="blog.Dept">
SELECT * FROM blog
</select>
Deptにて;
public class Dept {

private int id[];
public int[] getId() {
return id;
}
public void setId(int[] id) {
this.id = id;
}
blogArticle.javaにて
public void load()throws Exception
{
SqlMapClient sqlMap = MyAppSqlConfig.getSqlMapInstance();
sqlMap.startTransaction();

Dept dept =
(Dept)sqlMap.queryForObject("getDept");
sqlMap.commitTransaction();
}
以下のエラーが出てしまいました
No type handler could be found to map the property 'id' to the column 'id'. One or both of the types, or the combination of types is not supported.
.
deptのところを
private int id[];
public int[] getId() {
return id;
}
public void setId(int[] id) {
this.id = id;
から
private int id;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
に変えるとエラーは無くなりますが・・・
しかしながら配列型のBeanでは受入はできないということでしょうか。うまい方法はないでしょうか。
ご教授の程よろしくお願い申し上げます。

A 回答 (1件)

List<Dept> list = sqlMap.queryForList("getDept");


じゃだめ?

どうしても配列で欲しかったら、
<select id="get_id_array">
select id from dept
</select>
List<int> list = sqlMap.queryForList("get_id_array");
int[] id = list.toArray(new int[list.size()]);
    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!