ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Samnang Chhun <samnang.ch...@gmail.com>
Subject RE: Complex Property Error
Date Thu, 19 Jul 2007 13:21:24 GMT
These are all of my class:

class Person
{

   public int _id;
   public string _name;
   public AddressInfo _address;

}
  
class AddressInfo
{
   public string _postalCode;
   public string _country;
   public List<AddressItem> _addressLines;
}

class AddressItem
{

   public string _type;
   public string _value;
}

<resultMaps>
                <resultMap id="rmSelectPerson" class="Person">
                   <result property="_id" column="ID"/>
                   <result property="_name" column="Name"/>
                   <result property="_address._postalCode"
column="PostalCode"/>
                   <result property="_address._country" column="Country"/>
                   <result property="_address._addressLines" column="_id"
select="SelectAddressLineByPersonID"/>
                </resultMap>
                
                <resultMap id="rmSelectAddressLine" class="AddressItem">
                  <result property="_type" column="type" />
                  <result property="_value" column="value" />
                </resultMap>
</resultMaps>

<statements>
    <select id="SelectPersonByID" resultMap="rmSelectPerson"
parameterClass="int">
                 SELECT id,Name,PostalCode,Country FROM vPerson WHERE id =
#value#
   </select>
                                
  <select id="SelectAddressLineByPersonID" resultMap="rmSelectAddressLine"
parameterClass="int">
                SELECT type,value FROM addressLines WHERE person_id =
#value#
 </select>
</statements>

Cheers,
Samnang

-----Original Message-----
From: matt [mailto:matt.grande@fluidmedia.com] 
Sent: Thursday, July 19, 2007 7:08 PM
To: user-cs@ibatis.apache.org
Subject: Re: Complex Property Error

Please tell me you're not actually calling them class1, class2, and 
class3.  And why would you send us example code with cryptic names?  
We're trying to help you.

Samnang Chhun wrote:
>
> Hi all,
>
>  
>
> I want to load data from the database and fill to object by using 
> complex properties, but I get an error when I execute.
>
> I have 3 classes:
>
>  
>
> class1
>
> {
>
>                 public  int _id;
>
>                 public string _name;
>
>                 public class2 _address;
>
> }
>
>  
>
> class2
>
> {
>
>                 public string _postalCode;
>
>                 public string _country;
>
>                 public List<class3> _addressLines;
>
> }
>
>  
>
> class3
>
> {
>
>                 public string _type;
>
>                 public string _value;
>
> }
>
> I have a sqlMap.xml :
>
> <resultMaps>
>
>                 <resultMap id="rmSelectClass1" class="Class1">
>
>                    <result property="_id" column="ID"/>
>
>                    <result property="_name" column="Name"/>
>
>                    <result property="_address._postalCode" 
> column="PostalCode"/>
>
>                    <result property="_address._country" column="Country"/>
>
>                    <result property="_address._addressLines" 
> column="_id" select="SelectClass3"/>
>
>                 </resultMap>
>
>                
>
>                 <resultMap id="rmSelectClass3" class="Class3">
>
>                   <result property="_type" column="type" />
>
>                   <result property="_value" column="value" />
>
>                 </resultMap>
>
> </resultMaps>
>
>  
>
> <statements>
>
>     <select id="SelectClass1ByID" resultMap="rmSelectClass1" 
> parameterClass="int">
>
>                  SELECT id,Name,PostalCode,Country FROM vPerson WHERE 
> id = #value#
>
>    </select>
>
>                                
>
>   <select id="SelectClass3ByPersonID" resultMap="rmSelectClass3" 
> parameterClass="int">
>
>                 SELECT type,value FROM addressLines WHERE person_id = 
> #value#
>
>  </select>
>
> </statements>
>
>  
>
> When I'm runing my test I'm getting following error:
>
> System.ArgumentException: Field '_addressLines' defined on type 
> 'class2' is not a field on the target object which is of type 'class1'.
>
> Any help?
>
> Thanks,
>
>  
>


-- 
--------------------------
Matt Grande
Software Developer
Fluid Media, Inc
Phone: (905) 523-5898
Fax: (905) 523-5769
Email: matt@fluidmedia.com



Mime
View raw message