-->
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.  [ 8 posts ] 
Author Message
 Post subject: some wishes to avoid damaged session after exception
PostPosted: Mon Nov 13, 2006 6:19 am 
Regular
Regular

Joined: Thu Dec 11, 2003 4:14 pm
Posts: 86
Location: Hibernate 3 + annotations, Oracle 9i, PostgreSQL 8.0, Java 1.5.0
Hi!

I (also) use hibernate to access a legacy system which uses a tons of triggers and so on.
Often it is hard to check all constraints they use to avoid any exception which forces me to throw away the session and start over.

Well, in such a situation I exctly know which entity causes the fault as I do a flush() after each save() or modification.
Not very performant, I know, however....

Now it would be great if - in such a situation - it could be possible to remove a entity from the action (insert/update/delete) lists.
Maybe we can extend evict() to do so?

Also it would be nice if the Exception has a getErrorEntity() (or something like this) which allows us to retrieve the entity which caused the exception.
Just in case I'll move away from the flush() call ;-)


What do you think?

Thannks!
Ciao,
Mario


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 13, 2006 6:46 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
not possible (especially since the errors can be many other things and thus we cannot guarantee that the session nor objectgrpah is consistent)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 13, 2006 6:59 am 
Regular
Regular

Joined: Thu Dec 11, 2003 4:14 pm
Posts: 86
Location: Hibernate 3 + annotations, Oracle 9i, PostgreSQL 8.0, Java 1.5.0
Hmmm ....

Why not leave the decision to the developer if the objectgraph is still consistent?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 13, 2006 7:02 am 
Expert
Expert

Joined: Tue Dec 07, 2004 6:57 am
Posts: 285
Location: Nürnberg, Germany
Hi,
removing one entity from the action queues is pretty dangerous with regards to foreign key relationships. in addition to that it is obvious that this is against the principles of a transation: either the unit of work succeeds or it fails.

_________________
Please don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 13, 2006 7:09 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
if the objectgraph is consistent then just open a new session and reattach the object graph.

But as I said if an exception occur we cannot guarantee object graph NOR session consistency.

Object graph is only one half of this.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 13, 2006 7:20 am 
Regular
Regular

Joined: Thu Dec 11, 2003 4:14 pm
Posts: 86
Location: Hibernate 3 + annotations, Oracle 9i, PostgreSQL 8.0, Java 1.5.0
Especially when you e.g. do mass data imports you'll only have commit() after - say - every 100 or even more imported records.

If you commit() after each record your performance will be extremely poor. And no, its not always possible to use a command-line tool for importing data.

Now, if there is an exception in one of the records you often simply would like to log it and continue.
In such a situation the object graph for the imported entity will also be very small, if it even exists, and I easily can decide if its save to remove the entity in question from the actionQueue.


But ok, it looks like we have to live with that it wont work ;-)

Thanks for your answers!!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 13, 2006 7:21 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
use StatelessSession if you want more raw control

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 13, 2006 8:09 am 
Regular
Regular

Joined: Thu Dec 11, 2003 4:14 pm
Posts: 86
Location: Hibernate 3 + annotations, Oracle 9i, PostgreSQL 8.0, Java 1.5.0
Yea, this might be a solution for the outlined sceneario.

Thanks for the hint, I'll give it a try.

Ciao,
Mario


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