Hi,
I am trying to implement a self referential many to many relationship.
Is following code correct?
@Entity
public class Book {
@Id @GeneratedValue(strategy=GenerationType.AUTO)
Long bookId;
@Version
Long version;
@ManyToMany(mappedBy="linkedBooks")
Collection<Book> linkedBooks;
public Collection<Book> getLinkedBooks() {
return linkedBooks;
}
public void setLinkedBooks(Collection<Book> linkedBooks) {
this.linkedBooks = linkedBooks;
}
public Long getBookId() {
return BookId;
}
public void setBookId(Long BookId) {
this.BookId = BookId;
}
public Long getVersion() {
return version;
}
public void setVersion(Long version) {
this.version = version;
}
}