• Post Reply Bookmark Topic Watch Topic
  • New Topic

EntityManager.remove()  RSS feed

Mark Redmond
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am using JPA - Toplink with Derby DB.

My question is, if I use EntityManager.remove() and the argument entity object I give does not have a corresponding record in the underlying DB, will the EntityManager.remove() method throw an Exception or does it just go on pretending like everything is hunky dory?

I have checked the API JavaDocs and there are three exceptions thrown by EntityManager.remove() but I couldn't see one for the case I describe above.

So I presume the workaround would be to do a find() and check the result of that first, but if there's another way please let me know as I would like to make my code more succinct.

Thanks in advance.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!