Hi,
I am facing a couple of problems primarily due to my limited knowledge yet on associations (but still learning). Any help would be helpful
I got two entities sharing a One-To-One primary key association: Portfolio <-> Holder
Definition of the Portfolio Entity
@OneToOne (cascade = {CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REMOVE}) @PrimaryKeyJoinColumn public Holder getHolder() { return holder; }
Definition of the Holder Entity
@OneToOne(optional = false) @PrimaryKeyJoinColumn public Portfolio getPortfolio() { return portfolio; }
ID Definition for the Holder entity
@Id @GeneratedValue(generator="portfolioSharedPKGenerator") which is a foreign key strategy generator using a custom annotation
Now my questions:
A -> Is it possible to delete a Holder without going through the deletion of a portfolio. I dont want to use the Holder object directly
B -> When I try deletion of the Holder directly using a simple method like
holderDao.remove(11673l) which calls entityManager.remove() I get to see that the entity does get loaded but a DELETE does not get fired. The following error gets thrown:
deleted entity passed to persist: [com.wm.om.model.SecondaryHolder#<null> This happens atSessionImpl.persistOnFlush and Cascade.cascadeToOne
Thanks in Advance
Rgds...VJ
|