-->
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.  [ 2 posts ] 
Author Message
 Post subject: handling transient entity in delete processing
PostPosted: Fri Aug 31, 2007 7:45 pm 
Newbie

Joined: Wed Jul 25, 2007 7:04 pm
Posts: 3
Hello,
I am using Hibernate 3.2.3 with JPA and Spring 2.0.

I constructed a trivial application, then wrote a test method. I have two instances and issued two deletes and got an exception

java.lang.IllegalArgumentException: Removing a detached instance

This is expected.



String restaurantName = "Dover Diner";
Restaurant restaurant = restaurantDao.findByName(restaurantName).get(0);
Restaurant rest2 = restaurantDao.findByName(restaurantName).get(0);
restaurantDao.delete(restaurant);
List<Restaurant> results = restaurantDao.findByName(restaurantName);
assertEquals(0, results.size());
restaurantDao.delete(rest2);



Next, I followed Section 2.2. of http://www.hibernate.org/hib_docs/annot ... ntity.html
and converted the entity to use a composite primary key, i.e. defining a new primary key class and refer to the primary key class from the entity. The unit test is still the same, but now the exception is gone. Instead, there is only an INFO message of
handling transient entity in delete processing
but no exception.

Are there any ways to configure so that Hibernate will throw an exception, so that my application can trap this kind of error?

Regards,
Simon


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 04, 2007 8:23 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
the second case, if true, is a bug, can you open a JIRA issue and attach a minimal testcase?

_________________
Emmanuel


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