My brain is starting to hurt thinking about this, is it as simple as:
@ManyToMany(mappedBy = "following", cascade = CascadeType.ALL)
private Set<User> followers = new HashSet<User>();
@ManyToMany(mappedBy = "followers", cascade = CascadeType.ALL)
private Set<User> following = new HashSet<User>();
Something like:
@ManyToMany(mappedBy = "following", cascade = CascadeType.ALL)
@JoinTable(name="UserRel",
joinColumns={@JoinColumn(name="ParentId")},
inverseJoinColumns={@JoinColumn(name="UserId")})
private Set<User> followers = new HashSet<User>();
@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name="UserRel",
joinColumns={@JoinColumn(name="UserId")},
inverseJoinColumns={@JoinColumn(name="ParentId")})
private Set<User> following = new HashSet<User>();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With