Duplicate entry in OneToOne relationship while update
Posted: Thu May 07, 2015 5:10 am
Hi All,
I have @OneToOne relationship between two entity in blc admin.
For example
1. Office
2. Office billing address
Now here office billing address is optional.
In OfficeImpl
@OneToOne(mappedBy = "office",targetEntity = OfficeBillingAddressImpl.class)
@Cascade(value={org.hibernate.annotations.CascadeType.MERGE, org.hibernate.annotations.CascadeType.PERSIST, org.hibernate.annotations.CascadeType.SAVE_UPDATE})
protected OfficeBillingAddress address;
In OfficeAddressImpl
@OneToOne(targetEntity = OfficeImpl.class)
@JoinColumn(name = "OFFICE_ID", unique = true)
private Office office;
Now, From BLC Admin UI, If I create Office with office address, it is working fine.
But if i create office first and save it.. after that when i update office with office address ,
at that time there is duplicate entry is falling in office address table, one has office_id and other has null.
Thanks,
Ankit
I have @OneToOne relationship between two entity in blc admin.
For example
1. Office
2. Office billing address
Now here office billing address is optional.
In OfficeImpl
@OneToOne(mappedBy = "office",targetEntity = OfficeBillingAddressImpl.class)
@Cascade(value={org.hibernate.annotations.CascadeType.MERGE, org.hibernate.annotations.CascadeType.PERSIST, org.hibernate.annotations.CascadeType.SAVE_UPDATE})
protected OfficeBillingAddress address;
In OfficeAddressImpl
@OneToOne(targetEntity = OfficeImpl.class)
@JoinColumn(name = "OFFICE_ID", unique = true)
private Office office;
Now, From BLC Admin UI, If I create Office with office address, it is working fine.
But if i create office first and save it.. after that when i update office with office address ,
at that time there is duplicate entry is falling in office address table, one has office_id and other has null.
Thanks,
Ankit