ibatis-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "S Boyd (JIRA)" <ibatis-...@incubator.apache.org>
Subject [jira] Created: (IBATIS-45) ProbeExceptions with complex beans
Date Wed, 05 Jan 2005 20:42:16 GMT
ProbeExceptions with complex beans

         Key: IBATIS-45
         URL: http://issues.apache.org/jira/browse/IBATIS-45
     Project: iBatis for Java
        Type: Bug
  Components: SQL Maps  
    Versions: 2.0.8, 2.0.9    
 Environment: XP Pro; jdk 1.4.2
    Reporter: S Boyd

When I create a resultMap that uses a complex bean that contains an
associated Map, a ProbeException is thrown in two places when I 
attempt to populate the map from the resultset using object
graph navigation.

For example:

public class Account{
   String id;
   Map demographics;
   // setters/getters left out

<resultMap id="accountResult" class="Account">
 <result property="id"                   column="id"                        />
 <result property="demographics.address" column="address" javaType="string" />
 <result property="demographics.city"    column="city"    javaType="string" />
 <result property="demographics.state"   column="state"                     />

The two places that ibatis will fail is during the sqlmap parsing phase where it uses introspection
on the result properties _if_ the javaType is not specified.  So in the resultMap above, "demographics.state"
will generate a ProbeException because ibatis cannot determine what type "state" is.  Of course,
it is not known until runtime because the value is stored in the Map "demographics".  Instead
of a ProbeException, I think it should assign to the property the UnknownTypeHandler or something
similar.  For now, the current workaround would be to include the javaType attribute.  

Now, the second and more important place where the ProbeException is thrown is during the
population of the object after the query is executed.  Since the parent class is a java bean,
the GenericProbe.setObject() method uses the JavaBeanProbe.setObject() which tries to force
"demographics" to have a g/setter methods for all three properties instead of just using Map.get()
and Map.set().  Now, if the ComplexBeanProbe.setObject() is used, then everything works as


This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
If you want more information on JIRA, or have a bug to report see:

View raw message