wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes Why is deleting an entity that doesn't exist succeeding? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Why is deleting an entity that doesn Watch "Why is deleting an entity that doesn New topic
Author

Why is deleting an entity that doesn't exist succeeding?

Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
Hi,

I'm using JPA 2.0, Hibernate 4.1.0.Final, Spring 3.1.1.RELEASE, and JUnit 4.8.1. I'm confused about why a JUnit test is NOT failing. I have this test



My code for deleting an entity is



Shouldn't the second call to "delete" result in some kind of exception since the entity was removed in the first call? My flush mode is set to AUTO (the default) and below is how I configure my entity manager in my JUnit Spring application context and persistence.xml. Why isn't the second delete call failing?



and here is the persistence.xml file


Salil Vverma
Ranch Hand

Joined: Sep 06, 2009
Posts: 253

Hey Dave,

why should it fail ?
In RDBMS, if you try to delete an non-existing entry from database using sql, database does not throw any exception/error. The statement succeeds with message that zero records impacted. Hibernate provides just a layer on top of database and does not create new behaviors


Regards
Salil Verma
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Why is deleting an entity that doesn't exist succeeding?
 
Similar Threads
Spring/JPA/TopLink 11g extensions
org.springframework.beans.factory.BeanCreationException
Spring 3
Conflicting persistence unit definitions
Spring / Hibernate / cxf problems connecting with oracle