We are doing a query on an object which has a 1:1 reference to another
object. The other object is the base class of a table which has an extent
with 6 variant classes. We are using an ojbConcreteClass to store the class
type in the table. The object we are doing a query on is also an extent.

Our query works correctly when we query on a field that is only first
object.

If we add a criteria to the query that references a field in the base class
of the referenced object (and in all the extent objects) we then get the
query repeated 6 times, presumably once for each extent class. This would
be OK except that the query neglects to specify the ojbConcreteClass for
the referenced object. So we end up with 4*6 rows returned instead of 4.

This is the query
          Criteria crit = new Criteria();
          crit.addEqualTo("company", searchForm.getCompany());
          crit.addEqualTo("product", searchForm.getProduct());
          crit.addEqualTo("baseOrder.account", searchForm.getAccount());
          crit.addEqualTo("status", searchForm.getState());
          crit.addEqualTo("referenceType",
ReferenceType.PURCHASE_ORDER.getCode());

This is the SQL statement produced. It appears 6 times in our logs.

SELECT * FROM OrderLines A0 INNER JOIN Orders A1 ON A0.COMPANY=A1.COMPANY
AND A0.REFERENCE_TYPE=A1.REFERENCE_TYPE AND
A0.REFERENCE_NUMBER=A1.REFERENCE_NUMBER WHERE ( ((((A0.COMPANY =  ? ) AND
A0.PRODUCT =  ? ) AND A1.ACCOUNT =  ? ) AND A0.STATUS =  ? ) AND
A0.REFERENCE_TYPE =  ? ) AND  (A0.CLASS_NAME =  ? ) ORDER BY 29

I have simplified the code and the SQL output for clarity.

The SQL needs to either only be issued once, or needs to specify
A1.CLASS_NAME for each SQL statement.

I am not sure where to correct this. Can anyone give some help? We are
using OJB 0.9.8.


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

Reply via email to