I have following mapping:
Code:
@Entity(name="risk")
@Table(name=Schema.S_RIZIKO)
@Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class RiskEntity extends AuditableEntity
{
private InsuredItemEntity m_insuredItemEntity;
.....
@ManyToOne(fetch=FetchType.LAZY)
@Cascade(org.hibernate.annotations.CascadeType.REPLICATE)
@JoinColumn(name="ID_PREDMET_ZAV", nullable=true)
@BatchSize(size=10)
public InsuredItemEntity getInsuredItemEntity()
{
return m_insuredItemEntity;
}
public void setInsuredItemEntity(InsuredItemEntity insuredItemEntity)
{
m_insuredItemEntity = insuredItemEntity;
}
}
If i do this
Code:
RiskEntity riskEntity1 = RiskEntity.get(1318897); //entityManager.find(entityClass, id);
InsuredItemEntity insuredItemEntity = riskEntity1.getInsuredItemEntity();
EntityHelper.deleteEntity(insuredItemEntity);
.
I get two deletes, one for InsuredItemEntity and one for RiskEntity.
I would expect this to happen if I used CascadeType.ALL.
Am I missing something here or is this a bug ?