hibernate异常:failed to lazily initialize a collection of role

设置lazy即可

private Set<UrsMemberMobile> ursMemberMobile = new HashSet<UrsMemberMobile>(0);
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "ursMember")
public Set<UrsMemberMobile> getUrsMemberMobile() {
return ursMemberMobile;
}




private UrsMember ursMember;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "member_id", nullable = false)
public UrsMember getUrsMember() {
return this.ursMember;
}


http://www.blogjava.net/caixuetao/articles/113433.html hibernate HibernateTemplate中HibernateCallback的事务

你可能感兴趣的:(Hibernate)