org.hibernate.HibernateException: collection is not associated with any session报错

@ManyToMany(fetch = FetchType.EAGER)
	@JoinTable(catalog = "book_project", name = "client_book", joinColumns = { @JoinColumn(name = "client", referencedColumnName = "name") }, inverseJoinColumns = { @JoinColumn(name = "book", referencedColumnName = "name") })
	java.util.Set<Book> books;

把domain中FetchType.EAGER改成FetchType.LAZY就可以了。

这里有个解释挺详细的。

hibernate懒加载

猜你喜欢

转载自blog.csdn.net/twentyseventh/article/details/79829211