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