-->
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.  [ 3 posts ] 
Author Message
 Post subject: Unusual Mapping
PostPosted: Mon Jan 22, 2007 2:39 pm 
Newbie

Joined: Thu Jan 04, 2007 1:02 pm
Posts: 3
Hello, I have the folowing problem. I have users entities. Every user refers a list of other users. I suppose this could be easly mapped with M-M, but the problem is that these relations between users, have to have an integer property wich represents the strenght of the relation.
Could somebody help me with an ideas, how to map this?


Top
 Profile  
 
 Post subject: Re: Unusual Mapping
PostPosted: Mon Jan 22, 2007 5:10 pm 
Newbie

Joined: Mon Jan 22, 2007 3:44 pm
Posts: 3
patzzzo wrote:
Hello, I have the folowing problem. I have users entities. Every user refers a list of other users. I suppose this could be easly mapped with M-M, but the problem is that these relations between users, have to have an integer property wich represents the strenght of the relation.
Could somebody help me with an ideas, how to map this?


You could just use 2x 1 - M relations
so one class would be
Code:
@Entity
class User {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    Long id;

}


and the relation:

Code:
@Entity
class Referer {
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      Long id;

      @ManyToOne
      User parent;

      @ManyToOne
      User child;

      int strength;
}



to bad we cant use a composite pk on parent and child :( and skip the Referer.id

anyway, you get the idea i hope


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 23, 2007 5:06 am 
Newbie

Joined: Thu Jan 04, 2007 1:02 pm
Posts: 3
Thank you for your answer. It would be good to somehow avoid the refereer id. It is realy completely useless.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.