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
|