I used mybatis 3.1 ga,
those are my JavaBean classes,
<b>
public class SearchObject {
private Long id;
private List<Long> childIdList = new ArrayList<Long>();
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public List<Long> getChildIdList () {
return childIdList;
}
public void setChildIdList (List<Long> childIdList ) {
this.childIdList = childIdList ;
}
}
public class ResultObject {
private String result;
public String getresult() {
return result;
}
public void setResult(String result) {
this.result = result;
}
}
</b>
and this is my sqlmapping file,
<i><select id="getView" parameterType="SearchObject"
resultType="ResultObject">
select o.result from table o
<where>
<if test="id != null ">
o.id = #{id}
</if>
<if test="childIdList.size() > 0">
and o.child in
<b><foreach item="item" index="index" open="(" close=")"
separator="," collection="childIdList" >
#{item}
</foreach></b>
</if>
</where>
</select></i>
when I execute I got error:
<b>### Error querying database. Cause:
org.apache.ibatis.reflection.ReflectionException: There is no getter
for property named '__frch_item_0' in 'SearchObject'
### The error may involve sqlmap.Search.getView-Inline
### The error occurred while setting parameters
### Cause: org.apache.ibatis.reflection.ReflectionException: There is
no getter for property named '__frch_item_0' in 'SearchObject'
ERROR [STDERR] org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause:
org.apache.ibatis.reflection.ReflectionException: There is no getter
for property named '__frch_item_0' in 'SearchObject'
### The error may involve sqlmap.CCSalesOrderItem.getCCSOItemView-
Inline
### The error occurred while setting parameters
### Cause: org.apache.ibatis.reflection.ReflectionException: There is
no getter for property named '__frch_item_0' in 'SearchObject'</b>
If I change the sql mapping to this,
<i><select id="getView" parameterType="SearchObject "
resultType="ResultObject">
select o.result from table o
<where>
<if test="id != null ">
o.id = #{id}
</if>
<if test="childIdList.size() > 0">
and o.child in
<b><foreach item="item" index="index" open="(" close=")"
separator="," collection="childIdList" >
#childIdList[${index}]
</foreach></b>
</if>
</where>
</select></i>
I got this error:
<b>### Error querying database. Cause:
org.apache.ibatis.executor.ExecutorException: There was no TypeHandler
found for parameter childIdList[0] of statement sqlmap.Search.getView
### The error may involve sqlmap.Search.getView-Inline
### The error occurred while setting parameters
### Cause: org.apache.ibatis.executor.ExecutorException: There was no
TypeHandler found for parameter childIdList[0] of statement
sqlmap.Search.getView</b>
and how to do foreach with enum?
now I use this to run ,
<i><b>#{childIdList[${index}], javaType=Long}
#{enmuLilst[${index}], javaType=myEnum} </b></i>
Do I have other way?