Доброго времени суток, всех с наступающим!
Начал знакомство с spring, проблемы с ManyToMany
@Entity
@Table(name = "genre")
public class Genre {
@Id
@GeneratedValue
@Column(name = "id")
private Long id;
@Column(name = "name")
private String name;
private Set<Book> books;
@ManyToMany(fetch = FetchType.LAZY, mappedBy = "genres")
public Set<Book> getBooks() {
return books;
}
public void setBooks(Set<Book> books) {
this.books = books;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
@Entity
@Table(name = "book")
public class Book {
@Id
@GeneratedValue(strategy= GenerationType.AUTO)
@Column(name = "id")
private Long id;
@Column(name = "name")
private String name;
@Column(name = "book_reviews")
private String bookReviews;
private Set<Genre> genres;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getBookReviews() {
return bookReviews;
}
public void setBookReviews(String bookReviews) {
this.bookReviews = bookReviews;
}
@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinTable(name = "genre_book", joinColumns = @JoinColumn(name = "book_id", referencedColumnName = "id"),
inverseJoinColumns = @JoinColumn(name = "genre_id", referencedColumnName = "id"))
public Set<Genre> getGenres() {
return genres;
}
public void setGenres(Set<Genre> genres) {
this.genres = genres;
}
}
выдает ошибку
Caused by: org.hibernate.MappingException: Could not determine type for: java.util.Set, at table: genre, for columns: [org.hibernate.mapping.Column(books)]