Joined: Mon Sep 27, 2004 6:52 pm Posts: 6 Location: US
|
I am trying to model a many-to-many relationship with a composite element and a many-to-one tag.
I was not able to frame the HQL to do the same. Any help is highly appreciated.
Hibernate version: 3.0
Mapping documents:
The mapping for Tour:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
package="com.princess.web.bean">
<class name="Tour" table="TOUR">
<id name="resTourId" type="string">
<column name="res_tour_id"/>
<generator class="uuid.hex"/>
</id>
<set name="tourDeparture" table="tour_departure">
<key column="res_tour_id" />
<composite-element class="com.princess.web.bean.TourDeparture">
<property name="resDepartDate" column="res_depart_date" type="date" />
<property name="resArriveDate" column="res_arrive_date" type="date" />
<many-to-one name="resVoyageId" column="res_voyage_id" class="com.princess.web.bean.Voyage" />
</composite-element>
</set>
<property name="resDescription" column="res_description" type="string" />
</class>
</hibernate-mapping>
The mapping for Voyage:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
package="com.princess.web.bean">
<class name="Voyage" table="VOYAGE">
<id name="resVoyageId" type="string">
<column name="res_voyage_id"/>
<generator class="uuid.hex"/>
</id>
<property name="resShipId" column="res_ship_id" type="string" />
</class>
</hibernate-mapping>
TourDeparture is the association table of Tour and Voyage, containing the following fields:
res_tour_id <fk>
res_voyage_id <fk>
res_depart_date
res_Arrive_date
can anyone help me in framing the HQL for
list of all tour for ships with resShipId="XX"?
Please note that resShipId is a field in Voyage.
|
|