Yeah.... In fact I think Set / SortedSet is more match to list for
relational model

On 1/9/07, Todorovich, Milo <[EMAIL PROTECTED]> wrote:



I have an bean that I'm trying to retrieve, and this bean has a collection
(java.util.Set) of other beans that I would like to lazily load. When I run
query I get the following exception:

com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in
com/tpc/ipartner/model/Person.xml.
--- The error occurred while applying a result map.
--- Check the Person.PersonResult.
--- The error happened while setting a property on the result object.
--- Cause: net.sf.cglib.beans.BulkBeanException:
$java.util.List$$EnhancerByCGLIB$$ab076133
        at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:188)

        at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForObject(GeneralStatement.java:104)
        at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:566)
        at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:541)
        at
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:106)
        at
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientImpl.java:83)
        at
com.tpc.ipartner.service.person.PersonServiceIBatis.main(PersonServiceIBatis.java:50)
Caused by: net.sf.cglib.beans.BulkBeanException:
$java.util.List$$EnhancerByCGLIB$$ab076133
        at
com.tpc.ipartner.model.Person$$BulkBeanByCGLIB$$689fafc7.setPropertyValues(<generated>)
        at
com.ibatis.sqlmap.engine.accessplan.EnhancedPropertyAccessPlan.setProperties(EnhancedPropertyAccessPlan.java:33)

        at
com.ibatis.sqlmap.engine.exchange.JavaBeanDataExchange.setData(JavaBeanDataExchange.java:112)
        at
com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.setResultObjectValues(BasicResultMap.java:373)
        at
com.ibatis.sqlmap.engine.mapping.statement.RowHandlerCallback.handleResultObject(RowHandlerCallback.java:64)
        at
com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(SqlExecutor.java:382)
        at
com.ibatis.sqlmap.engine.execution.SqlExecutor.handleMultipleResults(SqlExecutor.java:301)
        at
com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:190)
        at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteQuery(GeneralStatement.java:205)
        at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:173)

        ... 6 more
Caused by: java.lang.ClassCastException:
$java.util.List$$EnhancerByCGLIB$$ab076133
        ... 16 more


This happens before I even try to access the collection. It appears that
setPhones is being called with an enhanced list, as shown in the last line
of the stacktrace.


My bean is defined like this:

public class Person {
   private Integer id;
   private String firstName;
   private String lastName;
   private Set phones = new HashSet();

        . . .
   public Set getPhones() {
           return phones;
   }

   public void setPhones(Set phones) {
           this.phones = phones;
   }
}

The examples -- in "iBATIS in Action" and in the iBATIS-SqlMaps-2_en.pdf
that comes with the downlaod -- all use java.util.List, but do not
explicitly say that the collections must be a List. Is this the case? When I
change my bean to use a List for phones, everything works fine.

Thanks,
Milo-

Reply via email to