vohoanghiep103 / vaadin-appfoundation

Automatically exported from code.google.com/p/vaadin-appfoundation
0 stars 0 forks source link

JPAFacade fails when trying to delete a POJO that has already been deleted #22

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Quote from the delete method

// We need to merge this object to the database session, so that it
// can be deleted. We do this by actually fetching the object first.
Object entity = em.find(pojo.getClass(), pojo.getId());
// Now when we have a fresh instance of the entity which is attached
// to the JPA provider's session, we can remove the entity.
em.remove(entity);

If find returns null, then an IllegalArgumentException is thrown. This should 
be handled in a different way.

Original issue reported on code.google.com by kimp...@gmail.com on 9 May 2011 at 12:17