EntityManagergetReference(Class<T> entityClass,Object primaryKey) wrote:
If the requested instance does not exist in the database, throws EntityNotFoundException when the instance state is first accessed. (The persistence provider runtime is permitted to throw EntityNotFoundException when getReference(java.lang.Class, java.lang.Object) is called.)
I confused with this. It says that the given exception is thrown when the instance state is first accessed. But within brackets it says that exception is thrown when the method is invoked. What a conflicting idea is this? When will the exception actually throwable?
I just tried this in a SLSB's addItem method. There is no Seller on the DB with id "testing". Interestingly it failed with EntityNotFoundException on the second line which is when we are accesssing the state of the instance.