org.hibernate.NonUniqueObjectException: a different object with the same ide

org.hibernate.NonUniqueObjectException: a different object with the same ide


出现这种情况一般是一对多或者多对多级联方面,我的情况是两边同时级联 把关联表的留下,外界表的去除即可

    @OneToMany(mappedBy="admin")//,cascade=CascadeType.ALL)//,fetch=FetchType.EAGER)
    public Set<AdminRole> getAdminroles() {
        return adminroles;
    }

    @ManyToOne(cascade=CascadeType.ALL)//,fetch=FetchType.EAGER)
    @JoinColumn(name="adminId")
    public Admin getAdmin() {
        return admin;
    }


你可能感兴趣的:(object,ide)