One of the most interesting uses of an O/R mapper for me is to easily build
hierarchical structures. I have tried it with lazy loading, but there still
remain some problems. Since the tree I have to load is quite large, I don't
want to load a lot at a time, but use lazy loading. The problem below occurs
in both ways, though.

I have a class A with childs of the same class, connected through a "parent"
column in the database.

For this OQL select operation:
    SELECT c from A c where c.parent.id = $1

the generated SQL looks like this:

  SELECT  A.id,
   A_f0.id,
   A.parent
  FROM A A_0,
       A A_f0,
       A
  WHERE
   A.id *= A_f0.id
    AND
   A.parent=A_0.id
    AND (A_0.id = ?)

(Using SQL Server; I removed the quotes)

It seems to me that A_0 designates the parent object, A the objects I'm
querying and A_f0 the collection of childs of A. Then the outer join is
wrong. It should be:
    A.id *= A_f0.parent
I realized that the _manyKey entry in the FieldDescriptor of "childs" is
null. How is that possible?

My mapping.xml looks like this:

 <class name="A" identity="id" cache-type="none" key-generator="IDENTITY">
    <map-to table="A"/>

    <field name="childs" type="A" collection="collection" lazy="true">
           <sql many-key="parent"/>
    </field>

    <field name="id" type="integer">
           <sql name="id" type="integer"/>
    </field>

    <field name="parent" type="de.lmu.ip.search.categories.ConManCategory">
      <sql name="parent" />
    </field>
</class>

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to