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.  [ 6 posts ] 
Author Message
 Post subject: Update problem
PostPosted: Thu Aug 30, 2007 3:09 pm 
Newbie

Joined: Sun Mar 18, 2007 12:15 pm
Posts: 19
Hi
I have a fairly complex business class, consisting of properties and collection (bags) nestet i a couple of levels. I've chosed use many ISessions according to chapter 10.4.2 in the manual.

Using one Session I fetches a instance of my business class from the database.
The application modifies this instance by changing property valus and adding/deleting items from the collection. Next step for the application is to save the changes to the database.

The application creates a new session and performs:session.SaveOrUpdate(item)
(there is a bit session and transaction manipulation first)

This immediatly generates a exception with the following message..

Quote:
Message = "deleted object would be re-saved by cascade (remove deleted object from associations): 51, of class: xxxxxx"


The referenced class xxxxx in of one of the collections.

Can anyone explain whats gone wrong, and what to do.
//lg


Top
 Profile  
 
 Post subject: yes, a problem!
PostPosted: Thu Aug 30, 2007 9:42 pm 
Beginner
Beginner

Joined: Wed Aug 29, 2007 1:25 pm
Posts: 26
Location: Recife, PE, Brazil
I think my problem can be the same


http://forum.hibernate.org/viewtopic.php?t=979066

unhappily I dont know why

would you tell me if you found that solution please?
I could do the same


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 31, 2007 3:02 am 
Senior
Senior

Joined: Mon Aug 21, 2006 9:18 am
Posts: 179
Please post mappings and code. You are either deleting an entity from a collection incorrectly or your mapping's cascade isn't set properly.

Mike

_________________
If this helped...please remember to rate it!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 31, 2007 4:07 am 
Newbie

Joined: Tue Aug 15, 2006 11:01 am
Posts: 10
[quote="mnichols"]Please post mappings and code. You are either deleting an entity from a collection incorrectly or your mapping's cascade isn't set properly.

Mike[/quote]

Yeah, you need to look out for the Cascade:AllDeleteOrphans

You might end up having your item deleted because it was removed from one association, but then recreated because it's still a member of another association.

If you can get rid of the M:N association, perhaps making it two 1:M associations, do that. It'll make like easier.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 31, 2007 8:05 am 
Newbie

Joined: Sun Mar 18, 2007 12:15 pm
Posts: 19
mnichols wrote:
Please post mappings and code. You are either deleting an entity from a collection incorrectly or your mapping's cascade isn't set properly.

Mike


As I wrote, I've have a fairly complex application and .... posting the mappings.... well it will fill up quite a space....

To clearify. I have a business class "business" containing collections implemented by using List (list).

Removing a Entity from the List is done by :
business.list.RemoveAt[0]

The I excecute...:

session.SaveOrUpdate(business)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 31, 2007 8:10 am 
Newbie

Joined: Sun Mar 18, 2007 12:15 pm
Posts: 19
b3ardman wrote:
mnichols wrote:
Please post mappings and code. You are either deleting an entity from a collection incorrectly or your mapping's cascade isn't set properly.

Mike


Yeah, you need to look out for the Cascade:AllDeleteOrphans

You might end up having your item deleted because it was removed from one association, but then recreated because it's still a member of another association.

If you can get rid of the M:N association, perhaps making it two 1:M associations, do that. It'll make like easier.


A matter of fact,,, I've implemented Many-To-Many relationships by using a middle class and One-To-Many and Many-To-One associations. My problems seems to be this middle class.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.