2

I read about the error in title but I can't find suitable solution for my case, I have the following relation :

@Entity
public class Parent {


    @OneToMany(fetch = FetchType.EAGER,mappedBy = "parent",cascade = CascadeType.MERGE)
    @Fetch(FetchMode.SUBSELECT)
    private List<Child> child;
}


@Entity
public class Child {

    @EmbeddedId
    @JsonIgnore
    private CompositePK compositePK;

    @MapsId("compositeId")
    @ManyToOne
    @JoinColumn(name = "PARENT_ID")
    @JsonIgnore
    private Parent parent;

    @MapsId("AId")
    @JoinColumn(name = "A_ID")
    @OneToOne
    private A a;

}

I don't have a transnational over my method and no open sessions , the following line throws error when trying to merge parent and merge its Child entites: parent= parentRepository.save(parent);

A different object with the same identifier value was already associated with the session : [....CompositePK@22bf8646]; nested exception is javax.persistence.EntityExistsException: A different object with the same identifier value was already associated with the session : .......CompositeMedicinePK@22bf8646]"

any explanation ?

Mohammad Karmi
  • 1,403
  • 3
  • 26
  • 42

1 Answers1

0

It looks like this issue was fixed in hibernate version 5.0.10, 5.1.1, and 5.2.0. More information here: https://hibernate.atlassian.net/browse/HHH-10476

Pedro Madrid
  • 1,887
  • 1
  • 20
  • 32