IllegalStateException with Hibernate 4 and ManyToOne cascading

后端 未结 9 2207
梦如初夏
梦如初夏 2020-12-01 16:06

I\'ve got those two classes

MyItem Object:

@Entity
public class MyItem implements Serializable {

    @Id
    private Integer id;
    @ManyToOne(casc         


        
9条回答
  •  情话喂你
    2020-12-01 16:30

    Had the same exception (hibernate 4.3.0.CR2) tiring to save a object which is having two copies of a child object, got fixed by, in the entity from :

    @OneToOne(cascade = CascadeType.MERGE)
    private User reporter;
    @OneToOne(cascade = CascadeType.MERGE)
    private User assignedto;
    

    to just,

    @OneToOne
    private User reporter;
    @OneToOne
    private User assignedto;
    

    i don't know the reason though

提交回复
热议问题