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
edcf4a6369
commit
c2bb67515f
|
@ -385,10 +385,17 @@ public class DefaultLoadEventListener extends AbstractLockUpgradeEventListener i
|
|||
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