These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Querying an inheritance heirarchy
PostPosted: Thu Nov 06, 2003 5:07 am 
Newbie

Joined: Fri Sep 19, 2003 3:28 am
Posts: 1
Hi,

I'm trying to write a query to return a list of people that have a certain name and date of birth. The way the data is modelled is that each of these are created as seperate subclasses of a PersonCharacteristic class, this is the relevant part of the mapping file:

[code]
<hibernate-mapping>
<class
name="com.aniteps.nflms.data.PersonCharacteristicHib"
table="PersonCharacteristic"
dynamic-update="false"
dynamic-insert="false"
>

<id
name="characteristicId"
column="characteristicId"
type="java.lang.Integer"
>
<generator class="native">
<param name="sequence">person_chartc_sequence</param>
</generator>
</id>

<many-to-one
name="realPerson"
class="com.aniteps.nflms.data.RealPersonHib"
cascade="save-update"
outer-join="auto"
update="true"
insert="true"
column="personId"
not-null="true"
/>

<property
name="isCurrentValue"
type="java.lang.Boolean"
update="true"
insert="true"
column="isCurrentValue"
not-null="true"
/>

<property
name="validFromDate"
type="timestamp"
update="true"
insert="true"
column="validFromDate"
not-null="true"
/>

<joined-subclass
name="com.aniteps.nflms.data.PersonBirthHib"
table="PersonBirth"
dynamic-update="false"
dynamic-insert="false"
>
<key
column="characteristicId"
/>
<property
name="birthDate"
type="timestamp"
update="true"
insert="true"
column="birthDate"
not-null="true"
/>

<property
name="birthPlace"
type="java.lang.String"
update="true"
insert="true"
column="birthPlace"
length="50"
/>

</joined-subclass>
<joined-subclass
name="com.aniteps.nflms.data.PersonNameHib"
table="PersonName"
dynamic-update="false"
dynamic-insert="false"
>
<key
column="characteristicId"
/>
<property
name="forename"
type="java.lang.String"
update="true"
insert="true"
column="forename"
length="50"
not-null="true"
/>

<property
name="surname"
type="java.lang.String"
update="true"
insert="true"
column="surname"
length="50"
not-null="true"
/>

<many-to-one
name="title"
class="com.aniteps.nflms.data.TitleHib"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="titleID"
/>

[/code]

There seems to be no way of navigating between the tables/objects due to the inheritance relationship, or am I missing something?
I did find one way that seemed to work, which was just to list the PersonBirth and PersonName in the from clause of the query, but then Hibernate seems to generate a cross join, and it is possible that the date of birth would not exist for a person - so in this case I would get no results, even though the person had a name.

I'm using Hibernate 2.0.3. If anyone could give me any advice I'd be very grateful.

Cheers,

Matt


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.