clazz------student 1对多的关系
现在通过获取student对象后,再去懒加载获取clazz对象报错:
org.hibernate.LazyInitializationException Cannot evaluate com.framework.util.core.entity.onetomany.ClazzEntity_$$_javassist_5.toString()
@Entity @Table(name = "clazz") public class ClazzEntity extends BaseEntity { private String name; private String clazzNo; List<StudentEntity> studentEntityList; @Column(name = "name") public String getName() { return name; } public void setName(String name) { this.name = name; } @Column(name = "clazzNo") public String getClazzNo() { return clazzNo; } public void setClazzNo(String clazzNo) { this.clazzNo = clazzNo; } @OneToMany(mappedBy = "clazzEntity",cascade = CascadeType.ALL) public List<StudentEntity> getStudentEntityList() { return studentEntityList; } public void setStudentEntityList(List<StudentEntity> studentEntityList) { this.studentEntityList = studentEntityList; } }
@Entity @Table(name = "student") public class StudentEntity extends BaseEntity { private String name; private String studentNo; private ClazzEntity clazzEntity; @Column(name = "name") public String getName() { return name; } public void setName(String name) { this.name = name; } @Column(name = "studentNo") public String getStudentNo() { return studentNo; } public void setStudentNo(String studentNo) { this.studentNo = studentNo; } @ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.LAZY) public ClazzEntity getClazzEntity() { return clazzEntity; } public void setClazzEntity(ClazzEntity clazzEntity) { this.clazzEntity = clazzEntity; }
manytoone的级联关了none试了下,没用
楼主解决了吗?我也出现相同问题,求解
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。