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: EntityManger RuntimeExceptions Issues
PostPosted: Mon Jun 16, 2008 5:24 pm 
Newbie

Joined: Mon Jun 16, 2008 5:01 pm
Posts: 1
Hi,

In JPA/Hibernmate, I was wondering why do methods in EntityManger (e.g persist,merge) throw RuntimeExceptions(e.g. IllegalStateException, IllegalArgumentException) insteadof PersistenceException or an appropriate subclass of it? If I see the API doc, it looks valid to have RuneTimeExceptions subclasses being thrown, but in real scenario, we are loosing important information hanging underneath.

Here is an example that I would like to give.

In my database table, I have three columns, col1, col2 and col3. col1 is the Pk and col2 and col3 are Foreign Keys(FK) and are nullable.
Values in col2 and col3 are mutually exclusive and should be unique ids. For some reason, the values (ids) in col2 and col3 got generated as same.
Because of this, during a delete process, as I loop thru to delete each object, I got the following exception during merge operation

java.lang.IllegalArgumentException: org.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations): [com.test.impl.Test #14910fb3-df28-4f70-ab43-a559e81a125f]

org.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations): [com.test.impl.Test#05b35b80-141e-485c-9f39-a1d8902623b5]


Now, as you see,if in my DAO,if I catch PersistenceException, the above exception will go unhandled. My question is: should not the exception org.hibernate.ObjectDeletedException be part of PersistenceException rather than being subclassed from IllegalArgumentException?

Can someone please enlighten on this issue?

Thanks in advance.
raj


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.