JPA 2.0 does not specify the behaviour of a persistence provider when
the application accesses an unloaded member of a detached entity.
In this case, Hibernate throws a LazyInitializationException, whereas
OpenJPA just leaves the member uninitialized which leads to a rather
non-descriptive NullPointerException.
It would help JPA users to write portable code if there were a standard
exception for this standard scenario.
Proposal for JPA 2.1:
The persistence provider MUST throw a
javax.persistence.LazyLoadException (derived from
javax.persistence.PersistenceException) when the application accesses a
member of a detached entity for which PersistenceUtil.isLoaded() returns
false.
Best regards,
Harald