Java Mailing List Archive

http://www.java2.5341.com/

Home » user-java.ibatis »

iBATIS 3 dynamic sql 'foreach' list got problem.

bruce666

2010-06-08

Replies: Find Java Web Hosting

Author LoginPost Reply

I am used ibatis 3.0 GA;

those are my JavaBean classes,

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;
}
}

and this is my sqlmapping file,

<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
    <foreach item="item" index="index" open="(" close=")" separator=","
collection="childIdList" >
        #{item}
    </foreach>
  </if>
  </where>
</select>

when I execute I got error:

### 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'

If I change the sql mapping to this,

<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
    <foreach item="item" index="index" open="(" close=")" separator=","
collection="childIdList" >
        #childIdList[${index}]
    </foreach>
  </if>
  </where>
</select>

I got this error:

### 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

where cause the error?
--
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@(protected)
For additional commands, e-mail: user-java-help@(protected)

©2008 java2.5341.com - Jax Systems, LLC, U.S.A.