Hmm. it seems a good under-desk gibbering session is helps focus the brain.
Once that was over with, I copied the generated finder code (below) into an
EJB of my own and executed it, getting the same results - not rows in the
ResultSet. I then wasted a whack of time trying to lay my eyeballs on the
actual final SQL statement being tossed at the database. No luck there, no
amount of downcasting to assorted Oracle JDBC Driver Statement classes would
produce a way to get a human readable parameterized SQL statement. No
matter, though, since by chance I spotted the problem in the generated code:

THE ORION-GENERATED CODE REVERSES THE ORDER OF THE STATEMENT PARAMETERS!!!

Notice the criteria in the where clause: first is
CatalogEntryEJB.catalogIdentity, second is CatalogEntryEJB.catalogLocale.
These are the two fields of the composite primary key of CatalogEJB, a
String and a Locale respectively.

Now look at the code that inserts the values for these parameters:

First is: statement.setString(1,
com.evermind.util.ObjectUtils.toString(primaryKey398.locale));
And second is: statement.setString(2, primaryKey398.identity);

The locale is being inserted where the identity should be, and vice-versa.

Bugzilla Bug #379 has been posted. Anybody got a non-stomach-churningly-ugly
workaround idea?

P. Pontbriand
Canlink Interactive Technologies, Inc.


----- Original Message -----
From: "Peter Pontbriand" <[EMAIL PROTECTED]>
To: "Orion-Interest" <[EMAIL PROTECTED]>
Sent: Tuesday, March 27, 2001 12:27 PM
Subject: Collection Finders With Entity Argument Always Return Empty
Collection


> ----------------
> java.sql.PreparedStatement statement =
connection.getCustomStatement("select
> CatalogEntryEJB.identity, CatalogEntryEJB.catalogIdentity,
> CatalogEntryEJB.catalogLocale, CatalogEntryEJB.label,
> CatalogEntryEJB.targetRoleIdentity, CatalogEntryEJB.referenceidentity,
> CatalogEntryEJB.price, CatalogEntryEJB.discountRate,
> CatalogEntryEJB.parentreferenceidentity, CatalogEntryEJB.referenceTypeInt,
> CatalogEntryEJB.productCode, CatalogEntryEJB.description,
> CatalogEntryEJB.extendedDescription, CatalogEntryEJB.listIndex,
> CatalogEntryEJB.created, CatalogEntryEJB.creator,
CatalogEntryEJB.modified,
> CatalogEntryEJB.modifier from CatalogEntryEJB where
> CatalogEntryEJB.catalogIdentity = ? and CatalogEntryEJB.catalogLocale =
?");
> try {
>     com.canlink.components.base.LocalizedEntityPK primaryKey398 =
>     argument0 == null ? null :
>         ((com.canlink.components.base.LocalizedEntityPK)
> argument0.getPrimaryKey());
>     {
>         if (primaryKey398 == null) {
>             if (((java.util.Locale) null) == null) statement.setNull(1,
> java.sql.Types.VARCHAR);
>             else
>                 statement.setString(1,
>
> com.evermind.util.ObjectUtils.toString(((java.util.Locale) null)));
>             if (((java.lang.String) null) == null) statement.setNull(2,
> java.sql.Types.VARCHAR);
>             else
>                 statement.setString(2, ((java.lang.String) null));
>         }
>         else {
>             if (primaryKey398.locale == null) statement.setNull(1,
> java.sql.Types.VARCHAR);
>             else
>                 statement.setString(1,
>
> com.evermind.util.ObjectUtils.toString(primaryKey398.locale));
>             if (primaryKey398.identity == null) statement.setNull(2,
> java.sql.Types.VARCHAR);
>             else
>                 statement.setString(2, primaryKey398.identity);
>         }
>     }
> }
> finally {
> }
> java.sql.ResultSet set = statement.executeQuery();
> while (set.next()) {
>     ....
> }
> ----------------



Reply via email to