In my data model, I have several different reasons. I am trying to use JAX = B to get XML representations in data models, however I read that for relationships from one to several:
@XmlInverseReference
required for the back of the display. I believe that this is for using different types of sampling (e.g. LAZY and EAGER). I donβt know exactly how this annotation works. Does it use reverse pointers to ensure that data is not retrieved when specified in specific fields? I also don't know if I need to comment on many of the many relationships with the above annotation or not.
Here is a custom class that has many, many relationships with itself, i.e. the user can be friends with many other users. Should I annotate the getter with @XmlInverseReference?
@Entity @Table(name = "users") public class User implements Serializable { ... // bi-directional many-to-many association to User @ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH }) @JoinTable(name = "friends", joinColumns = { @JoinColumn(name = "uid") }, inverseJoinColumns = { @JoinColumn(name = "frienduId") }) private List<User> friends; /** * @return * * gets the list of users this user is friends with */ public List<User> getFriends() { return this.friends; } /** * @param friendsList * * sets the users friends list */ public void setFriends(List<User> friendsList) { this.friends = friendsList; }
Any help or guidance is greatly appreciated.
source share