this is a known issue (sorry forget to answer your previous post). I checked in a test called InheritanceMultipleTableTest#testQuery_InheritedReference a few days ago.
I don't know a workaround for this problem. If you declare the reference in the sub-class Person too you have to modify the sub-class table and this will cause side-effects if you want all User with a specific status.
The problem is that the path "userStatus.name" could not be resolved by SqlGeneratorDefaultImpl.
regards, Armin
Keith Rogers wrote:
It seems to me that if you define a reference in a base class, and then have another class that inherits from it, then the reference-descriptor elements are not inherited.
For example, using the example at the end of the mail, if you query and
retrieve a User, you can use a getUserStatus() method to retrieve the
correct UserStatus object.
However, if you query and retrieve a Person, you can get the correct id
of the user status (using a getUserStatusId() method), but calling
getUserStatus() will return null. Is this the correct behaviour, or have I made a mistake in the
configuration? If this is the correct behaviour, how could I work around
it? I'm sure this could be done using the "mapping each class to a
distinct table" inheritence strategy, but this would involve modifying
an existing database, which I am reluctant to do for compatability
reasons.
Example - please assume that relevent get/set methods are implemented
public class User { protected int id; protected String username; protected String password; protected int userStatusId; protected UserStatus userStatus; }
public class Person extends User { protected String surname; protected String forename; }
public class UserStatus { protected int id; protected String name; }
<class-descriptor class="User" table="users">
<field-descriptor name="id" column="user_id" jdbc-type="INTEGER" primarykey="true" autoincrement="true"/>
<field-descriptor name="username" column="username" jdbc-type="VARCHAR"/>
<field-descriptor name="password" column="password" jdbc-type="VARCHAR"/>
<field-descriptor name="userStatusId" column="status" jdbc-type="INTEGER"/>
<reference-descriptor name="userLevel"
class-ref="com.mp.hato.ojb.OJBUserLevel" auto-retrieve="true">
<foreignkey field-ref="userLevelId"/>
</reference-descriptor>
</class-descriptor>
<class-descriptor class="Person" table="people">
<field-descriptor name="id" column="id" jdbc-type="INTEGER" primarykey="true"/>
<field-descriptor name="surname" column="surname" jdbc-type="VARCHAR"/>
<field-descriptor name="forename" column="forename" jdbc-type="VARCHAR"/>
<reference-descriptor name="super"
class-ref="com.mp.hato.ojb.OJBUser" auto-retrieve="true"
auto-update="true" auto-delete="true">
<foreignkey field-ref="id"/>
</reference-descriptor>
</class-descriptor>
<class-descriptor class="UserStatus" table="user_status"> <field-descriptor name="id" column="id" jdbc-type="INTEGER" primarykey="true"/> <field-descriptor name="name" column="name" jdbc-type="VARCHAR"/> </class-descriptor>
The information in this e-mail is confidential and intended to be solely for the use of the addressee(s) and may contain copyright and/or legally privileged information. If you are not the addressee (or responsible for delivery of the message to the addressee) please e-mail us at [EMAIL PROTECTED] and delete the message from your computer; copying, distribution, use or disclosure of its contents is strictly prohibited. As Internet communications are capable of data corruption no responsibility is accepted for changes made to this message after it was sent. For this reason it may be inappropriate to rely on advice contained in any e-mail without obtaining written confirmation of it. In addition, no liability or responsibility is accepted for viruses and it is your responsibility to scan attachments (if any). Please note that for business purposes, outgoing and incoming emails from and to the company may be monitored and recorded.
Mouchel Parkman UK Ltd, Registered in England at West Hall, Parvis Road, West Byfleet, Surrey UK KT14 6EZ Registered No : 1686040
--------------------------------------------------------------------- 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]
