I have a super class, AbstractPerson, that defines a bunch of properties and joins two tables, Person_appearance, and Person_App_Relationship. The subclass, Appearance, has a couple named queries that get instances of the subclass. There's nothing special that has to be done in the named query because of the join. You just use the class name and hibernate handles the join under the covers.
Code:
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping default-access="org.egcrc.cfr.hibernate.MyBasicPropertyAccessor" default-cascade="none">
<class name="org.egcrc.cfr.common.AbstractPerson" table="PERSON_APPEARANCE" lazy="true" discriminator-value="-1">
<id name="myId" column="PERSON_PK" type="long" unsaved-value="null">
<generator class="native"/>
</id>
<discriminator column="IS_POPULATION" type="integer"/>
... bunch of properties ...
<join table="PERSON_APP_RELATIONSHIP" inverse="false">
<key column="PERSON_FK" not-null="true"/>
<many-to-one name="myNormalizedRecord" column="NORM_REC_FK" class="org.egcrc.cfr.normalized.NormalizedRecord"/>
<many-to-one name="myFather" class="org.egcrc.cfr.common.AbstractPerson" column="FATHER_FK" cascade="save-update"/>
<many-to-one name="myMother" class="org.egcrc.cfr.common.AbstractPerson" column="MOTHER_FK" cascade="save-update"/>
<many-to-one name="myHusband" class="org.egcrc.cfr.common.AbstractPerson" column="HUSBAND_FK" cascade="save-update"/> <many-to-one name="myWife" class="org.egcrc.cfr.common.AbstractPerson" column="WIFE_FK" cascade="save-update"/>
<property name="myIsPopulation_" column="IS_POPULATION"/>
</join>
</class>
</hibernate-mapping>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping default-access="org.egcrc.cfr.hibernate.MyBasicPropertyAccessor" default-cascade="none">
<subclass name="org.egcrc.cfr.normalized.Appearance" extends="org.egcrc.cfr.common.AbstractPerson" discriminator-value="0" lazy="true" proxy="org.egcrc.cfr.normalized.Appearance">
<many-to-one name="myPopulationRecord" class="org.egcrc.cfr.population.CompositePerson" column="MERGED_APPEARANCE_FK" cascade="none"/>
</subclass>
<!-- Get all appearances that did not link to another appearance -->
<query name="getUnlinkedAppearances">
<![CDATA[from Appearance as appearance where appearance.myId not in (select pl.myAppearance1 from ProposedLink as pl) and appearance.myId not in (select pl.myAppearance2 from ProposedLink as pl)]]>
</query>
<!-- Get all appearances that are not associated with a population record. -->
<query name="getUnmergedAppearances">
<![CDATA[from Appearance as appearance where appearance.myPopulationRecord is null]]>
</query>
</hibernate-mapping>
Feel free to ask questions about this example.
Please rate me if this helps. I'm running low on credits ;-).