Hibernate Version: 2.1 With Spring 1.0.3 with JBoss 3.2.3, Mysql 4.0.15
I have a table that stores the project information. Projects can belong to project groups, which are basically projects too(they are differentiated by a type column). My mapping for the projectgroups column looks like this
<id name="projectID" column="PROJECT_ID" unsaved-value=-1/>
<set name="groupIDs" table="PROJECT_PROJECTGROUP" lazy="false">
<key column="PROJECT_ID"/>
<element column="PROJECT_GROUP_ID" type="integer"/>
</set>
This creates two tables, PROJECT which contains the id column and otherproject related columns and a PROJECT_PROJECTGROUP table that has two columns, PROJECT_ID and PROJECT_GROUP_ID which are both foreign keys to the PROJECT TAble. For e.g. in PROJECT Table
Project Type Name
1 Group TestGroup1
2 Member TestProject1
and PROJECT_PROJECTGROUP containing
PROJECT_ID PROJECT_GROUP_ID
2 1
This works fine. Now im trying to give the projectgroup id and retrieve the list of projects that belong to this project group.
I tried all combinations but couldnt retrieve this. Im using MySQL 4 so the last attempt at doing something like
"from Project proj where proj in elements(proj.groupIDs)" doesnt work as well.(Due to sub-selects).
What is the best way to do this? I can feed in the project group id and would like thelist of projects that belong to that group.
Thanks so much
Raja
|