mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-08 12:14:47 +00:00
HHH-14537 EntityNotFoundException thrown when non-existing association with @NotFound(IGNORE) mapped has proxy in PersistenceContext
(cherry picked from commit 3c1e16e06ce7232fbe69bf1a3322d3f251a8bfbb)
This commit is contained in:
parent
672a7e6a00
commit
106df75f20
@ -367,12 +367,19 @@ private Object returnNarrowedProxy(
|
||||
if ( !options.isAllowProxyCreation() ) {
|
||||
impl = load( event, persister, keyToLoad, options );
|
||||
if ( impl == null ) {
|
||||
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() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return persistenceContext.narrowProxy( proxy, persister, keyToLoad, impl );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user