-->
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: Odd One-To-Many Set doing odd things..
PostPosted: Tue Jul 28, 2009 2:05 pm 
Newbie

Joined: Tue Jul 28, 2009 1:31 pm
Posts: 4
Hello All,

I have something of an odd setup that I cannot seem to get to work properly. I have roles and functions... while roles are stored on the database it makes sense to store the functions on the jre. When I try to update a role it acts as if there can only be one of each function... IE if I try to update role 1 with function a and b then it works... but if I then try to update role 2 with just function a then role 1 will have function b and role 2 will have function a... let me show you my setup.

Role.hbm.xml
Code:
<hibernate-mapping package="nhweb.obj">
   <class name="Role" table="role">
      <id name="id" type="int" column="role_id">
         <generator class="increment"/>
      </id>

      <set name="permissions" cascade="all" lazy="false" fetch="join">
            <key column="role_id" not-null="true" />
            <one-to-many class="Function" />
        </set>

      <property name="name" type="string" column="name" />
   </class>
</hibernate-mapping>



Function.hbm.xml
Code:
<hibernate-mapping package="nhweb.obj">
   <class name="Function" table="permissions">
      <id name="id" type="int" column="function_id" />
   </class>
</hibernate-mapping>


Basically the permissions table keeps track of all the function_ids that have been assigned to a role. It is probably very obvious what my mistake is but I have been messing with this for some time now so please help... I am guessing it has something to do with Function.hbm.xml having function_id as a primary key but it isnt...


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.