Hi
I have 2 class with "denpends" relationship.Say class Master and class Detail.
I use collection="arraylist" in my mapping.xml file.
I am sure that I have only 2 rows of master data in my database.
And I have 6 rows of detail data.Each master row has 3 detail rows associated with it.
When I exexuting the OQL "SELECT master FROM MASTER master  WHERE master.id < 100".
I got a QueryResults, and I get the size of this resultset using the method "size" in class QueryResults.
I should get a number of 2, right? But I got 6. Ok, this maybe the number of detail rows (since I haven't read the all of the documentation, I don't know if this is the right answer).
But when I go through the resultset with method "next" in a while loop.
I only got 1 object of MASTER class and the loop ends.
 
If I execute a different query "SELECT master FROM MASTER master".
I got 2 when I call QueryResults.size() and I and iterate 2 objects of class MASTER.just as I expected.
 
Can you please give me a hand to explan this situration?
Thanks!
 
Regards
 
Howard
 
ps : below is part of my mapping file, If I should provide more information about this.Please let me know.
 
--------------------------------------------------------------------------------------------------
<class name="Assess" identity="id" key-generator="MAX">
        <cache-type type="none" />
        <map-to table="npd_assess" />
 
        <field name="id" type="integer">
        <sql name="id" type="integer" dirty="ignore"/>
     </field>
     
     <field name="title" type="string">
        <sql name="title" type="char" dirty="ignore"/>
     </field>
     
     <field name="from_date" type="date">
     <sql name="from_date" type="char[yyyy-MM-dd]"/>
    </field>
    
    <field name="to_date" type="date">
     <sql name="to_date" type="char[yyyy-MM-dd]"/>
    </field>
    
    <field name="details" type="Assess_detail" collection="arraylist" required="true">
        <sql many-key="assess_id"/>
     </field>
     
    </class>
   
    <class name="Assess_detail"
     depends="Assess" identity="assess_detail_id" key-generator="MAX">
        <cache-type type="none" />
        <map-to table="npd_assess_detail" />
 
        <field name="assess_detail_id" type="integer">
        <sql name="assess_detail_id" type="integer" dirty="ignore"/>
     </field>
     
     <field name="master" type="Assess" required="true">
        <sql name="assess_id" dirty="ignore"/>
     </field>
     
     <field name="npd" type="NPD_Npd" required="true">
        <sql name="npd_id" dirty="ignore"/>
     </field>
     
     <field name="score" type="integer">
        <sql name="score" type="integer" dirty="ignore"/>
     </field>
     
     <field name="grade" type="string">
        <sql name="grade" type="char" dirty="ignore"/>
     </field>
    </class>
 

Reply via email to