hi charles,

this should do it:

Query q = QueryFactory.newQuery(A.class, c);
broker.getCollectionByQuery(q);

fyi there's a testcase dealing with multi-joined-tables InheritanceMultipleTableTest. this testcase requires the latest from repository to pass completely.

hth
jakob

Charles N. Harvey III wrote:

Hello.
The other day I embarked on a little journey by mapping classes on
multiple joined tables.  It went really well.  I am very excited to
see it working and to see it working so well.

One question though, and I can use the example on the site to demonstrate.

<!-- Definitions for org.apache.ojb.broker.A -->
<class-descriptor
       class="org.apache.ojb.broker.A"
       table="A_TABLE">
   <field-descriptor
           name="id"
           column="ID"
           jdbc-type="INTEGER"
           primarykey="true"
           autoincrement="true"/>
   <field-descriptor
           name="someValueFromA"
           column="VALUE_"
           jdbc-type="INTEGER"/>
</class-descriptor>

<class-descriptor
       class="org.apache.ojb.broker.B"
       table="B_TABLE">
   <field-descriptor
           name="id"
           column="ID"
           jdbc-type="INTEGER"
           primarykey="true"
           autoincrement="true"/>
   <field-descriptor
           name="someValueFromB"
           column="VALUE_"
           jdbc-type="INTEGER"/>
   <reference-descriptor
           name="super"
           class-ref="org.apache.ojb.broker.A"
           auto-retrieve="true"
           auto-update="true"
           auto-delete="true">
       <foreignkey
               field-ref="id"/>
   </reference-descriptor>
</class-descriptor>


Ok. So, I can now do this:


Criteria c = new Criteria();
c.addEqualTo("someValueFromA", new Integer(1));
c.addEqualTo("someValueFromB", new Integer(2));
Query q = QueryFactory.newQuery(B.class, c);
broker.getCollectionByQuery(q);

Which is really cool. But, how can I select ONLY CLASSES FROM A? Every time
I insert a B it inserts into A. And that's how it is supposed to work. But
I also insert plain 'ol As into A. So how can I select a collection of ONLY A?


Is this possible? I think it is but I have to do a sub query like,
SELECT * FROM A WHERE NOT IN (SELECT ID FROM B) Am I correct? And, how do I
do that in OJB?


Thanks a lot for the help.


Charlie




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to