HHH-14537 EntityNotFoundException thrown when non-existing association with @NotFound(IGNORE) mapped has proxy in PersistenceContext
(cherry picked from commit 3c1e16e06c
)
This commit is contained in:
parent
672a7e6a00
commit
106df75f20
|
@ -367,10 +367,17 @@ public class DefaultLoadEventListener implements LoadEventListener {
|
|||
if ( !options.isAllowProxyCreation() ) {
|
||||
impl = load( event, persister, keyToLoad, options );
|
||||
if ( impl == null ) {
|
||||
event.getSession()
|
||||
.getFactory()
|
||||
.getEntityNotFoundDelegate()
|
||||
.handleEntityNotFound( persister.getEntityName(), keyToLoad.getIdentifier() );
|
||||
if ( options == LoadEventListener.INTERNAL_LOAD_NULLABLE ) {
|
||||
// The proxy is for a non-existing association mapped as @NotFound.
|
||||
// Don't throw an exeption; just return null.
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
event.getSession()
|
||||
.getFactory()
|
||||
.getEntityNotFoundDelegate()
|
||||
.handleEntityNotFound( persister.getEntityName(), keyToLoad.getIdentifier() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue