iBATIS 3 dynamic sql 'foreach' list got problem.

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

iBATIS 3 dynamic sql 'foreach' list got problem.

bruce666
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?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: iBATIS 3 dynamic sql 'foreach' list got problem.

bruce666
and how to foreach a enum list when using sqlmap?

bruce666 wrote
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?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: iBATIS 3 dynamic sql 'foreach' list got problem.

Larry Meadors
The ibatis project has moved and been renamed.

It is no longer being maintained as an Apache project, but has moved
(along with the development team) here:

http://www.mybatis.org/

Please join us at the new location by joining the mailing list here:

http://groups.google.com/group/mybatis-user

Larry

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...