-->
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.  [ 2 posts ] 
Author Message
 Post subject: Many To Many Cross table question
PostPosted: Thu Aug 30, 2007 8:53 am 
Newbie

Joined: Mon Jun 11, 2007 5:45 am
Posts: 8
I have this simple scenario, but I can't get my head around it:

Table Group (id, description)
Table SubGroup (id, description)
Table GroupSubGroup (id, group_id, subgroup_id)

So, Groups can have several SubGroups, and SubGroups can have several Groups.

The users need to add and delete both ways.

Mapping looks like this:

Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="Foo.Framework.Domain" assembly="Foo.Framework" schema="FOO">
  <class name="Group" table="GROUP" lazy="false">
    <id name="Code" column="CODE" type="string">
      <generator class="assigned"/>
    </id>
  <property name="Description" column="DES" type="string" />
  <bag name="SubGroups" lazy="false" table="GROUPSUBGROUP" cascade="all">
    <key column="GROUP_CODE"/>
    <many-to-many column="SUBGROUP_CODE"  class="Foo.Framework.Domain.Subgroup, Foo.Framework"/>
  </bag>
</class>
</hibernate-mapping>


When Hibernate tries to (re)insert entries for the cross-table, I do need an Id provided by an Oracle-sequence...
What syntax am I needing here?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 17, 2007 8:32 am 
Newbie

Joined: Mon Jun 11, 2007 5:45 am
Posts: 8
So,

This problem got solved by removing the extra primary key and using a composite key on the 2 ref'd keys.

Everything worked like a charm, until today, I hear that I cannot use this approach, because there NEEDS to be a separate (sequenced) primary key for the many-to-many table.

I can't find out how to merge the Oracle Sequence into this (or any) many-to-many relation...

Any help?


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

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.