I wish to execute a query where I return all the people that belong to a specific phone number. The names of the people are in a table that is separate from the phone numbers. The HBM files are as follows:
Code:
<hibernate-mapping>
<class name="zarnett.at.mac.maschool.addressBook.dataModels.Student" table="STUDENT">
<id name="id" type="int" column="STUDENT_ID">
<meta attribute="scope-set">protected</meta>
<generator class="native"/>
</id>
<property name="firstName" type="string" not-null="true">
<meta attribute="use-in-tostring">true</meta>
<column name="FIRST_NAME" not-null="true" index="TRACK_TITLE"/>
</property>
<property name="lastName" type="string" not-null="true">
<meta attribute="use-in-tostring">true</meta>
<column name="LAST_NAME" not-null="true"
index="LAST_NAME_INDEX"/>
</property>
<property name="studentCode" type="string" not-null="true">
<meta attribute="use-in-tostring">true</meta>
<column name="STUDENT_CODE" not-null="true"
index="STUDENT_CODE_INDEX"/>
</property>
<set name="contactDetails" table="STUDENT_CONTACT">
<key column="STUDENT_CODE"/>
<many-to-many class="zarnett.at.mac.maschool.addressBook.dataModels.ContactDetails"
column="CONTACT_DETAILS_ID"/>
</set>
</class>
</hibernate-mapping>
and
Code:
<hibernate-mapping>
<class name="zarnett.at.mac.maschool.addressBook.dataModels.ContactDetails" table="CONTACT_DETAILS">
<id name="id" type="int" column="CONTACT_DETAILS_ID">
<meta attribute="scope-set">protected</meta>
<generator class="native"/>
</id>
<property name="contactType" type="int" not-null="true">
<meta attribute="use-in-tostring">true</meta>
<column name="CONTACT_TYPE" not-null="true"/>
</property>
<property name="contactData" type="string" not-null="true">
<meta attribute="use-in-tostring">true</meta>
<column name="CONTACT_DATA" not-null="true" />
</property>
</class>
</hibernate-mapping>
I should be able to say "given phone number 867-5309" give me all the people with that phone number.
Can anyone give me the HSQL call that would allow such a query to take place? I'm probably making the ones I tried more complicated than they need to be and thus, the errors.
Thanks for any help.