-->
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: how to use a "link" table for getting a bag
PostPosted: Wed Jan 07, 2009 6:00 am 
Newbie

Joined: Wed Jan 07, 2009 5:54 am
Posts: 2
Hello,
here's my problem :

I have those sql table (i short them cause there are a lot of non useful informations)

USER : "id_user","profile_id"
PROFILE : ""profile_id","name" (something like (1,Admin), (2, SImpleUser), etc...)
FUNCTIONALITY_RIGHT : "functionalitiyroght_id" ,"profile_id", "functionality_id"
FUNCTIONALITY : "functionality_id", "name"

functionality_right link a profile with a functionality : a profile will have many functionalities.

I have a java object Profile, wich might have a List<Functionality> functionalities.
my problem is that i dont know i could i map profile and/or functionality, to "bypass" functionalityright (i dont want to map functionality right).

the goal is that with a user, i have to retrieve all the functionalities he can access.

I'm not really used to hibernate, i have read a lot of tutorial, but i dont find my solution.
anybody here can help me?

Thank's a lot


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 07, 2009 7:07 am 
Newbie

Joined: Wed Jan 07, 2009 5:54 am
Posts: 2
I think i have found the solution, but... there is a BIG bug.

First, my mapping file for Functionality :
<hibernate-mapping>
<class name="Functionality"
table="functionality">
<id name="id" column="functionality_id">
<generator class="native" />
</id>
<property name="name" type="string" />
<property name="groupId" column="functionalitygroup_id" />

<bag name="profiles" table="functionality_right">
<key column="functionalityright_id"></key>
<many-to-many class="Profile"
column="profile_id"
lazy="false" >
</many-to-many>
</bag>
</class>
</hibernate-mapping>

then for Profile :
<hibernate-mapping>
<class name="com.weidii.beans.Profile" table="profile">
<id name="id" column="profile_id">
<generator class="native" />
</id>
<property name="name" type="string" />
<bag name="functionalities" table="functionality_right">
<key column="functionalityright_id"></key>
<many-to-many class=Functionality" column="functionality_id" lazy="false">
</many-to-many>
</bag>
</class>
</hibernate-mapping>

Of course, my Java class get List of functionality / profile.

When i retrieve a profile, everything forks fine, except :

my functionalityright table is EMPTY (after my application run, cause before, i have datas in this table)
why???


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.