-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Shared Primary Key associations Deletion
PostPosted: Fri Jul 20, 2007 11:19 am 
Beginner
Beginner

Joined: Fri Apr 20, 2007 1:07 am
Posts: 23
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.