-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: collections of strings and not of beans
PostPosted: Sun Nov 09, 2003 5:08 pm 
Newbie

Joined: Sun Nov 09, 2003 4:40 pm
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.