Hey,
Can anyone help me. I have looked at the Hibernate Mapping DTD and can not figure out how to create a mapping of strings when it comes to two tables that are connected via another table. I know how to create a collection of strings when only two tables refer to each other:
<!-- This code is in the class hbm.xml file for the jars table -->
<set name="classes">
<key column="JarId"/>
<element column="ClassName" type="java.lang.String"/>
</set>
Where "classes" is a table that has a column named "JarId" that refers to a Jar table with id as it's primary key. "ClassName" is a column in the classes table. It looks like this:
jars || classes
--------||-------------
id (PK)|| JarId
______|| ClassName
This works for two tables but what if I have something like this:
jars || packagejars || packages
--------||--------------||------------
id (PK) || JarID || id (PK)
______|| PackageID || name
The "JarID" in "packagejars" refers to the "id" in "jars." The "PackageID" in "packagejars" refers to the "id" in "packages." I want a collection of strings which refer to packages.name that are linked to a jar in jars. What I have now is this:
<!-- This code is in the class hbm.xml file for the jars table -->
<set name="packages" table="packagejars">
<key column="JarID"/>
<many-to-many class="edu.ncsu.csc492f03.sas.form.hibernate.HibernateJavaPackage" column="PackageID"/>
</set>
It works but it gives me a collection of package objects. "edu.ncsu.csc492f03.sas.form.hibernate.HibernateJavaPackage" is the class for the table "packages." Is there a way I can get a collection of strings (that refer to packages.name) instead of objects.
Any help would be appreciated greatly,
Lee
|