Once you have called session.clear() loading an entity by the natural ID fails with a NPE
Caused by: java.lang.NullPointerException
at org.hibernate.internal.SessionImpl$BaseNaturalIdLoadAccessImpl.performAnyNeededCrossReferenceSynchronizations(SessionImpl.java:2509)
at org.hibernate.internal.SessionImpl$BaseNaturalIdLoadAccessImpl.resolveNaturalId(SessionImpl.java:2476)
at org.hibernate.internal.SessionImpl$NaturalIdLoadAccessImpl.load(SessionImpl.java:2582)
because the PersistenceContext is completely empty
|