• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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


 
Ranch Hand
Posts: 257
Hibernate Oracle Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic