I have Three entity class on OneToOne Relation Product->SkuImpl->SkuAvailabilityImpl I just need to add a product, so records are inserting into sku table simultaneously into SkuAvailability table
SkuImpl.java
@Entity
public class SkuImpl implements Sku {
@OneToOne(targetEntity=SkuAvailabilityImpl.class, cascade={cascadeType.ALL},fetch=FetchType.EAGER)
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
@LazyCollection(LazyCollectionOption.FALSE)
protected SkuAvailability totalSku;
//setter and getters
}
SkuAvailabilityImpl.java
@Entity
public class SkuAvailabilityImpl implements SkuAvailability{
@OneToOne(optional=true,targetEntity=SkuImpl.class)
@Cascade(value={org.hibernate.annotations.CascadeType.ALL})
@JoinColumn(name="SKU_ID", referencedColumnName='SKU_ID',insertable=false,updatable=false)
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
protected Sku sku;
//setter and getters
}
sku database table is
SKU_ID | NAME | QUANTITY | SKU_AVAILABILITY_ID
--------+--------+----------+--------------------
| | |
All records are inserting fine, but the problem here is, an extra column is adding on the above table with the name totalSku_SKU_AVAILABILITY_ID like below
SKU_ID | NAME | QUANTITY | SKU_AVAILABILITY_ID |totalSku_SKU_AVAILABILITY_ID
--------+--------+----------+--------------------
101 |product1| 200 | | 503
I tried deleting that column, but it is creating again. I am not understanding why this column is adding can anyone help me how to stop this?