I am using the EntityManager#find() method to load a managed entity. The problem is that if the managed entity does not exist in database, EntityNotFoundException is not thrown. Here is the code that I am using.
Code:
try {
tran.begin();
State managedState = em.find(State.class,state.getId());
tran.commit();
return managedState;
}
catch (Throwable t) {....
If in the database, the given state.getId() does not exists, then I expect that hibernate should throw EntityNotFoundException. But that is not happening.
regards,
Nirvan.