-->
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.  [ 3 posts ] 
Author Message
 Post subject: Insert/Delete Causing Failures with Extended Persistence
PostPosted: Mon Nov 29, 2010 11:32 am 
Newbie

Joined: Fri Jul 09, 2010 1:24 pm
Posts: 11
So I am using Hibernate to manage a large object graph using an extended persistence context. I am running into issues where an object is added to the persistence context. The object is mapped to a collection encapsulated within an entity via a OneToMany mapping. The object that is added to the collection is a complex type with other encapsulated entities. Later during the usage of my application, the user deletes this object and my application logic removes the object from the collection and calls remove(...) on the EntityManager.

My problem happens when I flush the persistence context. An INSERT is fire for this object and constraint violations are thrown since some of the database required fields are null. Is there a way to prevent this INSERT from firing in the first place since the object was marked for deletion from the persistence context? Detaching the object from the persistence context seems a viable option, but I am not sure if this is "best practice".

Thanks in advance!

Specs:
JPA 2
Hibernate 3.6.0.Final
Java 5 and 6


Top
 Profile  
 
 Post subject: Re: Insert/Delete Causing Failures with Extended Persistence
PostPosted: Mon Nov 29, 2010 2:18 pm 
Newbie

Joined: Fri Jul 09, 2010 1:24 pm
Posts: 11
For what it is worth, I was thinking the issue is loosely related to viewtopic.php?p=2191664


Top
 Profile  
 
 Post subject: Re: Insert/Delete Causing Failures with Extended Persistence
PostPosted: Wed Dec 01, 2010 2:02 am 
Newbie

Joined: Fri Jul 09, 2010 1:24 pm
Posts: 11
So I assume there is no way to achieve this in Hibernate. Having searched the forums, I suppose Gavin would say this is intentional, but it certainly feels like something that should configurable. Anyway, I am running into issues with removing items from the collections of this large object graph. It is the dreaded "deleted entity passed to persist". I assumed that deleteOrphan would take care of removing the entire graph and therefore certain objects wouldn't be passed to persist. Do I need to unlink all my entities before I flush regardless of this attribute?

Thanks


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

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.