HHH-7949 - Prevent lazy loading collections for bidirectional associations where not modified when withModifiedFlag is used.
This commit is contained in:
parent
1081c02c6b
commit
59870d0a14
|
@ -193,10 +193,18 @@ public abstract class AbstractCollectionMapper<T> implements PropertyMapper {
|
||||||
data.put( propertyData.getModifiedFlagPropertyName(), true );
|
data.put( propertyData.getModifiedFlagPropertyName(), true );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// HHH-7949 - Performance optimization to avoid lazy-fetching collections that have
|
||||||
|
// not been changed for deriving the modified flags value.
|
||||||
|
final PersistentCollection pc = (PersistentCollection) newObj;
|
||||||
|
if ( ( pc != null && !pc.isDirty() ) || ( newObj == null && oldObj == null ) ) {
|
||||||
|
data.put( propertyData.getModifiedFlagPropertyName(), false );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final List<PersistentCollectionChangeData> changes = mapCollectionChanges(
|
final List<PersistentCollectionChangeData> changes = mapCollectionChanges(
|
||||||
session,
|
session,
|
||||||
commonCollectionMapperData.getCollectionReferencingPropertyData().getName(),
|
commonCollectionMapperData.getCollectionReferencingPropertyData().getName(),
|
||||||
(PersistentCollection) newObj,
|
pc,
|
||||||
(Serializable) oldObj,
|
(Serializable) oldObj,
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue