ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Mills <developm...@peter.mills.to>
Subject Re: Possible Bug: ResultMapping with a resultmap with no direct Properties
Date Sun, 16 Jul 2006 16:38:18 GMT
I followed the progress of the query in the debugger. 

Yes, I'm calling QueryForObject to grab a Customer by ID.  Strangely, 
the sequence of object construction goes as follows:

1. Creates the Customer
2. Creates the ReferencePeople object
3. Injects a null ReferencePeople object into Customer
4. Creates a Salesman object
5. injects the Salesman into the ReferencePeople object

Despite fully constructing the ReferencePeople object, it injects null 
into Customer, unless I add the direct (non "select") attribute to 
ReferencePeople.

Ron Grabowski wrote:

>Do you have logging enabled? Is the sql for GetSalesmanByCustomerID
>being executed? I assume you're calling QueryForObject.
>
>--- Peter Mills <development@peter.mills.to> wrote:
>
>  
>
>>Thank you for the quick response. 
>>
>>Yes, I'm using DataMapper 1.5 Beta.  The useReflectionOptimizer
>>setting 
>>was enabled, but disabling it didn't help.
>>
>>Peter
>>
>>Ron Grabowski wrote:
>>
>>    
>>
>>>You're using DataMapper 1.5 Beta correct? 
>>>
>>>Is useReflectionOptimizer enabled?
>>>
>>>--- Peter Mills <development@peter.mills.to> wrote:
>>>
>>> 
>>>
>>>      
>>>
>>>>I'm having trouble with a resultmapping, using the latest beta of
>>>>        
>>>>
>>the
>>    
>>
>>>>mapper.
>>>>
>>>>The problem occurs when a resultMapping only contains properties
>>>>        
>>>>
>>with
>>    
>>
>>>>select attributes (no direct result properties).  In the example
>>>>below, 
>>>>I'm trying to map a ReferencePeople object to my Customer object.  
>>>>ReferencePeople is a simple class that contains a customer's
>>>>reference 
>>>>people at a company and some minimal logic.  As such, it contains
>>>>        
>>>>
>>no 
>>    
>>
>>>>properties other than other mapped objects (such as Salesman). 
>>>>        
>>>>
>>When 
>>    
>>
>>>>doing the mapping below, despite creating ReferencePeople abject
>>>>        
>>>>
>>and 
>>    
>>
>>>>adding a salesman to  it, Ibatis injects null into the
>>>>ReferencePeople 
>>>>property of Customer.  However, if I add any direct property to 
>>>>ReferencePeople, such as copying the Customer's version property in
>>>>        
>>>>
>>>>there, then Ibatis properly injects a ReferencePeople object into
>>>>Customer.
>>>>
>>>><resultMap id="Customer" class="Customer">
>>>>   <result property="CustomerID" column="CustomerID"/>
>>>>   <result property="ReferencePeople" 
>>>>resultMapping="Customer.ReferencePeopleResult"/>
>>>>   <result property="Version" column ="Version"/>
>>>></resultMap>
>>>>
>>>><resultMap id="ReferencePeopleResult" class="ReferencePeople">
>>>>   <result property="PreferredSalesman" column="PreferredSalesman"
>>>>        
>>>>
>>>>select="GetSalesmanByCustomerID"/>
>>>>  
>>>>   <!-- If I add a random property from Customer to
>>>>        
>>>>
>>ReferencePeople,
>>    
>>
>>>>so 
>>>>that it has a direct property, then everything works fine -->      
>>>>        
>>>>
>>>>   <!--<result property="Version" column ="Version"/>-->
>>>></resultMap>
>>>>
>>>>class customer
>>>>   properties: CustomerID: long, ReferencePeople: ReferencePeople,
>>>>        
>>>>
>>>>Version: long
>>>>
>>>>class ReferencePeople
>>>>   properties: PreferredSalesman: Salesman, Version: long (version
>>>>was 
>>>>only added in debugging and does not belong in ReferencePeople)
>>>>
>>>>DB:
>>>>   Customer and ReferencePeople information are both stored in the
>>>>        
>>>>
>>>>Customer Table, Salesman infromation is in its own table.
>>>>Cheers,
>>>>
>>>>Peter
>>>>
>>>>   
>>>>
>>>>        
>>>>
>>> 
>>>
>>>      
>>>
>>    
>>
>
>
>  
>


Mime
View raw message