-->
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.  [ 10 posts ] 
Author Message
 Post subject: Invalid State after SQL error
PostPosted: Tue Mar 23, 2004 11:04 am 
Newbie

Joined: Mon Mar 22, 2004 3:37 pm
Posts: 13
If a SQL error occurs during a Save or Update, my network of persistent objects are left in an invalid state: some sets are now empty, objects that have not been saved now have the id property set.

Is there a recommend way of avoiding this? I'm using the "two session" paradigm.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 23, 2004 11:14 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
A SQL error is fatal, close all Sessions and restart.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 23, 2004 11:25 am 
Newbie

Joined: Mon Mar 22, 2004 3:37 pm
Posts: 13
Thanks. I still have the problem that the network of objects is now trashed and the client must somehow recover. I don't think it is reasonable for me to require the clients to save a deep copy of the parent object prior to calling my stuff.

I have tried saveAndUpdateCopy(), without any different results. I must be missing some key concept of Hibernate ...I have read the Hibernate documentation. It all seems so straight forward, but I am unable to move past this issue.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 23, 2004 11:26 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
You can't recover from a database error. This is not a Hibernate issue.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject: I'm still missing something
PostPosted: Tue Mar 23, 2004 11:42 am 
Newbie

Joined: Mon Mar 22, 2004 3:37 pm
Posts: 13
Why does the network of objects that I'm persisting become trashed? I can deal with setting all the ids back to null, but why are objects being removed from collection? I've tried using lifecycle collection and just plain old one-to-many/many-to-one collection.

I'm still missing some key concept regarding the contract between Session and my code. I'm really curious why session is removing objects from my collections before it saves the parent object.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 23, 2004 11:48 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
You want JDO and transactional transient objects, probably. I don't see Hibernate removing your objects though, only IDs should be set. Collections are replaced with proxies, however, but that should also be transparent.

This is all guesswork, as long as you don't narrow your question to code, mappings, stracktrace and log.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 23, 2004 12:22 pm 
Newbie

Joined: Mon Mar 22, 2004 3:37 pm
Posts: 13
Thanks for all your help. At this point, it's time for me to bite the bullet and debug into the Hibernate code and see what is happening. I'm certain that I'm making a simple mistake somewhere.


Top
 Profile  
 
 Post subject: I'm still missing something
PostPosted: Tue Mar 23, 2004 1:19 pm 
Newbie

Joined: Mon Mar 22, 2004 3:37 pm
Posts: 13
...and I figured out what it is!!! A brain!!! Christian, let me give you my address so you can come over and kick me. All the problems were because the objects that I attempted to persist DO NOT implement Serializable. That might have been mentioned somewhere in the documentation :>)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 23, 2004 2:11 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Actually, thats not a requirement, but a recommendation.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject: competitive upgrade
PostPosted: Tue Mar 23, 2004 2:28 pm 
Newbie

Joined: Mon Mar 22, 2004 3:37 pm
Posts: 13
I think it should be upgraded to code orange: highly recommend.

Thanks again.


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