According to the JPA spec: ??The EntityNotFoundException is thrown by the persistence provider when an entityreference obtained by getReference is accessed but the entity does not exist.??
However, when you access the id field that you passed to the getReference call, no exception is thrown. Is this the correct behavior? From the logs, it doesn't run the SQL if you access the ID, but it runs it if you access any other field.
{code:java} @Entity(name = "fake_customer") public class FakeCustomer { private UUID id; private String name;
//getters and setters } {code}
{code:java} FakeCustomer c = new FakeCustomer(UUID.randomUUID(), ""); .... final FakeCustomer reference = entityManager.getReference(FakeCustomer.class, c.getId()); final UUID id = reference.getId(); // Works fine final String name = reference.getName(); // Throws exception {code}
|
|