Java OrphanRemoving=true引发org.hibernate.AssertionFailure异常

Java OrphanRemoving=true引发org.hibernate.AssertionFailure异常,java,hibernate,Java,Hibernate,我有一个公共实体,它具有双向关联。实体的代码是下一个: @Entity @Table(name = "TableName") public class Entity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private int ID; ... @OneToMany(mappedBy = "OtherEntityID", cascade = CascadeType.ALL,

我有一个公共实体,它具有双向关联。实体的代码是下一个:

@Entity
@Table(name = "TableName")
public class Entity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private int ID;

    ...

    @OneToMany(mappedBy = "OtherEntityID", cascade = CascadeType.ALL, orphanRemoval = true)
    private List<OtherEntity> OtherEntity;

    ...
但是,Hibernate返回此异常:

Exception in thread "main" org.hibernate.AssertionFailure: collection owner not associated with session
如果我设置了
orphanRemoving=false
,那么我可以毫无问题地删除实体。在使用
Hibernate.initialize()
删除实体之前,我已尝试初始化集合,但没有任何更改。 我想这与集合是加载的
LAZY
而不是
EAGGER
有关,但我还没有找到任何解决方案。有人能帮我吗


PD:我正在使用Hibernate 5.2.4 Final。

你找到答案了吗?
Exception in thread "main" org.hibernate.AssertionFailure: collection owner not associated with session