-->
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: linking primary keys of 2 tables
PostPosted: Fri Feb 26, 2010 8:38 am 
Newbie

Joined: Wed Dec 30, 2009 7:00 am
Posts: 4
Hi all,

what I am trying to do is the following: I have multiple tables. All these tables have a primary key called id (I make sure the keys are unique over all the tables). Then I have a table that should contain all the keys, because I want to be able to reference to all these objects from a central table (I need to be able to associate users to these objects to see which user can alter/view specific objects)

Is this possible to do with hibernate? Can I manually add constraints (I looked in the documentation, but I can't seem to find anything about it).

Is there an alternative way of dealing with this problem?

kind regards

Guy


Top
 Profile  
 
 Post subject: Re: linking primary keys of 2 tables
PostPosted: Fri Feb 26, 2010 10:06 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Quote:
(I need to be able to associate users to these objects to see which user can alter/view specific objects)


This I would simple map with unidirectional to many relations,
then you don't need to do that weird thing with the 'super-table' holding a reference to each key.

Quote:
@Entity
public class MySuperclass {
@ManyToMany
Set<User> alter;

@ManyToMany
Set<User> view;
}


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.