Hibernate懒加载出现问题: LazyInitializationException :Cannot evaluate com.entity.onetomany.ClazzEntity_$$_javassist_5.toString()

丶wandy 发布于 2016/08/17 15:34
阅读 4K+
收藏 0

开源之夏第三届火热来袭,高校学生参与赢万元奖金!>>>

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;
    }



请教下是什么原因?

加载中
0
skhuhu
skhuhu
many to one 的级联关了 none
丶wandy
丶wandy
试了下,没用
0
b
boy_1215

楼主解决了吗?我也出现相同问题,求解

OSCHINA
登录后可查看更多优质内容
返回顶部
顶部