kuros / random-jpa

Create random test data for JPA/Hibernate entities.
GNU General Public License v3.0
26 stars 4 forks source link

Entity was not getting persisted with detached error if reference column maps to same id #24

Closed kuros closed 6 years ago

kuros commented 6 years ago

Scenario:

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

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    @Column(name = "name")
    private Long id;

    @OneToOne
    @JoinColumn(name = "id")
    private ReferencedEntity refEntity;

  ...
}

In this type of entity, Persistence was failing giving detached/constaint violation error intermittently