Hello all,
I have an interesting problem.
Problem Overview: I am writing a project management system, central to this system is the work breakdown structure (wbs). I assign resources (person objects) to the WBS object via a list (resources). Unfortunatley the relationship has two unique attributes hours ( the hours the resource is estimated to need) and percent ( the percent of the resources time we estimate they will devote to this issue.) In order to caputre this information I created an intersection table (wbsresource) with fields for the wbs ID, person ID, hours and percent. To map this I used the composite mapping. (Mapping document included below).
Problem: I need to develop a query in hibernate (if possible) where I can retrieve all wbs items for a given person. Remember in the object model the person objects are held in a list attribute on the wbs object. Please note that I am able to save wbs items and retrieve wbs items by project, so the mapping works.
Thanks
Glenn
Hibernate version:2.x
Mapping documents: <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<!-- DO NOT EDIT: This is a generated file that is synchronized --> <!-- by MyEclipse Hibernate tool integration. --> <!-- Created Thu Feb 17 13:47:16 GMT-05:00 2005 --> <hibernate-mapping >
<class name="com.bankofny.girt.pa.ejb.wbs.Wbs" table="wbs"> <id name="idPk" column="ID_PK" type="int"> <generator class="native"/> </id> <property name="name" column="NAME" type="java.lang.String" not-null="true" /> <property name="duration" column="DURATION" type="int" /> <property name="oriEarlyStart" column="ORI_EARLY_START" type="java.util.Date" /> <property name="oriEarlyFinish" column="ORI_EARLY_FINISH" type="java.util.Date" /> <property name="oriLateStart" column="ORI_LATE_START" type="java.util.Date" /> <property name="oriLateFinish" column="ORI_LATE_FINISH" type="java.util.Date" /> <property name="earlyStart" column="EARLY_START" type="java.util.Date" /> <property name="earlyFinish" column="EARLY_FINISH" type="java.util.Date" /> <property name="lateStart" column="LATE_START" type="java.util.Date" /> <property name="oriFloat" column="CURRENT_FLOAT" type="int" /> <property name="description" column="DESCRIPTION" type="java.lang.String" /> <property name="open" column="OPEN" type="boolean" not-null="true" /> <property name="projectIdPk" column="PROJECT_ID_PK_FK" type="int"/> <property name="workTicketGenerated" column="WORK_TICKET_GENERATED" type="int"/> <list name="resources" table="wbsresource" inverse="false" cascade="none"> <key column="wbs_id_pk" /> <index column = "wbs_index" /> <composite-element class="com.bankofny.girt.pa.ejb.person.Person" > <property name="id" column="PERSON_ID_PK" type="int" /> <property name="hours" column="HOURS" type="int" /> <property name="percent" column="PERCENT" type="int" /> </composite-element> </list> <list name="selectedDependendcies" table="WBSDEPENDENDCIES" inverse="false" cascade="none"> <key column="parent_id_pk" /> <index column = "wbs_index" /> <many-to-many class="com.bankofny.girt.pa.ejb.wbs.Wbs" column="child_id_pk"> </many-to-many> </list> </class> </hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:MySQL 3.6
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
|