HHH-15835 Avoid using functions in PersistenceContext#clear implementation

This commit is contained in:
Sanne Grinovero 2022-12-07 11:50:46 +00:00
parent 6b1cbc0640
commit 52b143c613
1 changed files with 5 additions and 4 deletions

View File

@ -228,11 +228,12 @@ public class StatefulPersistenceContext implements PersistenceContext {
@Override
public void clear() {
if ( proxiesByKey != null ) {
proxiesByKey.forEach( (k,o) -> {
if ( o != null) {
HibernateProxy.extractLazyInitializer( o ).unsetSession();
//Strictly avoid lambdas in this case
for ( Object value : proxiesByKey.values() ) {
if ( value != null) {
HibernateProxy.extractLazyInitializer( value ).unsetSession();
}
} );
}
}
entityEntryContext.processEachEntity( StatefulPersistenceContext::processEntityOnClear );