Hi Joel,

AFAIK this is a n:m association. Please refer to tutorial 3, section on n:m mappings.

cheers,
Thomas

Joel Wickard wrote:
I'm having trouble figuring out how to map an object to two tables for example:

In my database I have 3 tables like so:

-----------------------
| users |
-----------------------
| tableId |
| userId |
| userName |
-----------------------

----------------------
| groupmembers |
-----------------------
| tableId |
| userId |
| groupId |
----------------------

-----------------------
| groups |
-----------------------
| tableId |
| groupId |
| groupName |
______________


I have an object user that I want to map to the database:

Class Group {
groupId
groupName
}


Class user{
Group[] groups
userName
userId
}

I can figure out how to map a user to the database using field-descriptors and a collection-descriptor, but what I want to find out
is how to map a Group so that it it creates a join between the groups and group memberships table.

This is what I have so far:

<?xml version="1.0" encoding="UTF-8" ?>

<class-descriptor
class="com..users.Employee"
table="users">

<field-descriptor id="1"
name="tableId"
column="tableid"
jdbc-type="INTEGER"
primarykey="true"
autoincrement="true"/>
<field-descriptor id="2"
name="id"
column="userid"
jdbc-type="VARCHAR"/>
<field-descriptor id="3"
name="userName"
column="username"
jdbc-type="VARCHAR"/> <field-descriptor id="4"
name="userPass"
column="userpass"
jdbc-type="VARCHAR"/>
<collection-descriptor id="1"
name="groups"
element-class-ref="com.litriusgroup.litriFrame.users.UserGroup" />
</class-descriptor>

<class-descriptor
class="com.users.UserGroup"
table="groupmembers">
</class-descriptor>

I hope this made sense, any input would be helpful.


--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>





--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to