Beginner |
 |
Joined: Fri Jun 04, 2004 12:50 pm Posts: 32
|
I have a question which I think should be quite easy to answer. I have looked everywhere for an answer and cannot seem to be able to find it partly I am guessing because I do not know the best way to ask the question.
I have two entities, a family and a camper which families can have many of. I am quite capable of querying for all families where lastName = xxxx where it returns all families and associated campers. But, I am not quite sure how to query for all families where camper lastName = yyyy and it will return all families and associated campers.
Is there a single link that someone can point me to for an example of this?
Thanks
Tom
Hibernate version:
2.1.8. the version incorporated into JBoss 4.0
Mapping documents:
The two entities are: Family
<class name="com.camp.common.family.Family" table="tblFamily">
<id name="familyID" type="integer">
<column name="id_family" sql-type="integer" not-null="true"/>
<generator class="sequence">
<param name="sequence">tblfamily_id_family_seq</param>
</generator>
</id>
<property name="parentOneLastName">
<column name="p1_last_name" sql-type="char(64)" not-null="true"/>
</property>
<property name="parentOneFirstName">
<column name="p1_first_name" sql-type="char(64)" not-null="true"/>
</property>
<set name="campers" lazy="false" cascade="all-delete-orphan" inverse="true">
<key column="fk_id_family"/>
<one-to-many class="com.camp.common.camper.Camper"/>
</set>
</class>
and Camper
<class name="com.camp.common.camper.Camper" table="tblCamper">
<id name="camperID" type="integer">
<column name="id_camper" sql-type="integer" not-null="true"/>
<generator class="sequence">
<param name="sequence">tblcamper_id_camper_seq</param>
</generator>
</id>
<property name="lastName">
<column name="last" sql-type="char(32)" not-null="true"/>
</property>
<property name="firstName">
<column name="first" sql-type="char(32)" not-null="true"/>
</property>
<property name="gender">
<column name="gender" sql-type="boolean" not-null="false"/>
</property>
<many-to-one name="family" class="com.camp.common.family.Family" column="fk_id_family" not-null="true"/>
</class>
Code between sessionFactory.openSession() and session.close():
N/A
Full stack trace of any exception that occurs:
N/A
Name and version of the database you are using:
Postgres 7.4.1
The generated SQL (show_sql=true):
N/A
Debug level Hibernate log excerpt:
N/A
|
|