报错:
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: net.sppan.base.entity.User.organizations, could not initialize proxy - no Session
//已开始多对多设置的是懒加载,后来改称及加载就可以了
@ManyToMany(cascade = {CascadeType.REFRESH}, fetch = FetchType.LAZY)
@JoinTable(
name = "tb_user_organization",
joinColumns =
{@JoinColumn(name = "user_id")},
inverseJoinColumns =
{@JoinColumn(name = "organization_id")})
private java.util.Set<Organization> organizations;
////////////////////////////////////////////////////////////////////////////////////
@ManyToMany(cascade = {CascadeType.REFRESH}, fetch = FetchType.EAGER)
@JoinTable(
name = "tb_user_organization",
joinColumns =
{@JoinColumn(name = "user_id")},
inverseJoinColumns =
{@JoinColumn(name = "organization_id")})
private java.util.Set<Organization> organizations;