Hi everyone,

I have two entity classes AddressImpl and PersonAddressImpl,
PersonAddressImpl extending AddressImpl (below the interesting parts of my
Mapping). A third class - GaragaeImpl - holds a reference to an AddressImpl
(might be an AddressImpl or a PersonAddressImpl).

  <class-descriptor class="de.armax.ce.manager.entity.AddressImpl"
    table="Address">
    <extent-class class-ref="de.armax.ce.manager.entity.PersonAddressImpl"/>
    <field-descriptor autoincrement="true" primarykey="true" column="addOID"
jdbc-type="VARCHAR" name="oID"/>
    ...
  </class-descriptor>

  <class-descriptor class="de.armax.ce.manager.entity.PersonAddressImpl"
    table="PersonAddress">
    <field-descriptor autoincrement="true" primarykey="true" column="padOID"
jdbc-type="VARCHAR" name="oID"/>
    ...
  </class-descriptor>

  <class-descriptor class="de.armax.ce.manager.entity.GarageImpl"
    table="Garage">
    ...
    <field-descriptor column="garAddressOID" jdbc-type="VARCHAR"
name="addressOID"/>
    <reference-descriptor proxy="true" auto-delete="false"
auto-retrieve="true"
      auto-update="false" class-ref="de.armax.ce.manager.entity.AddressImpl"
name="address">
      <foreignkey field-ref="addressOID"/>
    </reference-descriptor>
    ...
  </class-descriptor>


As you can see, the primery key column has not the same name for the two
tables (whereas the field name is the same for both classes). That's the
source of my problem. I try to do a query by criteria with something like

  Criteria crit = new Criteria();
  crit.addEqualTo("address.aAddressField", aValue);
  Collection result =
broker.getCollectionByQuery(QueryFactory.newQuery(GarageImpl.class, crit));

The generated SQL looks like

  SELECT DISTINCT A0.gar* FROM Garage A0 LEFT OUTER JOIN Address A1 ON
A0.garAddressOID=A1.addOID LEFT OUTER JOIN PersonAddress A1E0 ON
A0.garAddressOID=A1E0.addOID ...

It seems that OJB is not aware of the different column names for the foreign
keys of PersonAddressImpl and AddressImpl entities (the problem only occurrs
for primary key columns, other columns are correctly mapped).

I would like to know if this is correct behaviour or not, in other words
does OJB allow the user to use different foreign key column names in one
extent or not. I would equally be interested in any suggestions how to get
my code running if possible without renaming the foreign key column of
PersonAddressImpl (this would break our global naming and design
conventions).

Thanks for any help,

Peter

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

Reply via email to