@@ -357,49 +357,54 @@ public boolean requiresDirtyCheck(Object entity) {
357
357
}
358
358
359
359
private boolean isUnequivocallyNonDirty (Object entity ) {
360
- if ( isSelfDirtinessTracker ( entity ) ) {
361
- final boolean uninitializedProxy ;
362
- if ( isPersistentAttributeInterceptable ( entity ) ) {
363
- final PersistentAttributeInterceptor interceptor =
364
- asPersistentAttributeInterceptable ( entity ).$$_hibernate_getInterceptor ();
365
- if ( interceptor instanceof EnhancementAsProxyLazinessInterceptor ) {
366
- EnhancementAsProxyLazinessInterceptor enhancementAsProxyLazinessInterceptor =
367
- (EnhancementAsProxyLazinessInterceptor ) interceptor ;
368
- return !enhancementAsProxyLazinessInterceptor .hasWrittenFieldNames (); //EARLY EXIT!
369
- }
370
- else {
371
- uninitializedProxy = false ;
372
- }
360
+ return isSelfDirtinessTracker ( entity )
361
+ ? isNonDirtyViaTracker ( entity )
362
+ : isNonDirtyViaCustomStrategy ( entity );
363
+ }
364
+
365
+ private boolean isNonDirtyViaCustomStrategy (Object entity ) {
366
+ if ( isPersistentAttributeInterceptable ( entity ) ) {
367
+ final PersistentAttributeInterceptor interceptor =
368
+ asPersistentAttributeInterceptable ( entity ).$$_hibernate_getInterceptor ();
369
+ if ( interceptor instanceof EnhancementAsProxyLazinessInterceptor ) {
370
+ // we never have to check an uninitialized proxy
371
+ // TODO: why do we not check !lazinessInterceptor.hasWrittenFieldNames()
372
+ // as we do below in isNonDirtyViaTracker() ?
373
+ return true ;
373
374
}
374
- else if ( isHibernateProxy ( entity ) ) {
375
- uninitializedProxy = extractLazyInitializer ( entity ).isUninitialized ();
375
+ }
376
+
377
+ final SessionImplementor session = getPersistenceContext ().getSession ().asSessionImplementor ();
378
+ final CustomEntityDirtinessStrategy customEntityDirtinessStrategy =
379
+ session .getFactory ().getCustomEntityDirtinessStrategy ();
380
+ return customEntityDirtinessStrategy .canDirtyCheck ( entity , getPersister (), session )
381
+ && !customEntityDirtinessStrategy .isDirty ( entity , getPersister (), session );
382
+ }
383
+
384
+ private boolean isNonDirtyViaTracker (Object entity ) {
385
+ final boolean uninitializedProxy ;
386
+ if ( isPersistentAttributeInterceptable ( entity ) ) {
387
+ final PersistentAttributeInterceptor interceptor =
388
+ asPersistentAttributeInterceptable ( entity ).$$_hibernate_getInterceptor ();
389
+ if ( interceptor instanceof EnhancementAsProxyLazinessInterceptor lazinessInterceptor ) {
390
+ return !lazinessInterceptor .hasWrittenFieldNames ();
376
391
}
377
392
else {
378
393
uninitializedProxy = false ;
379
394
}
380
- // we never have to check an uninitialized proxy
381
- return uninitializedProxy
382
- || !persister .hasCollections ()
383
- && !persister .hasMutableProperties ()
384
- && !asSelfDirtinessTracker ( entity ).$$_hibernate_hasDirtyAttributes ()
385
- && asManagedEntity ( entity ).$$_hibernate_useTracker ();
386
395
}
387
- else {
388
- if ( isPersistentAttributeInterceptable ( entity ) ) {
389
- final PersistentAttributeInterceptor interceptor =
390
- asPersistentAttributeInterceptable ( entity ).$$_hibernate_getInterceptor ();
391
- if ( interceptor instanceof EnhancementAsProxyLazinessInterceptor ) {
392
- // we never have to check an uninitialized proxy
393
- return true ; //EARLY EXIT!
394
- }
395
- }
396
-
397
- final SessionImplementor session = getPersistenceContext ().getSession ().asSessionImplementor ();
398
- final CustomEntityDirtinessStrategy customEntityDirtinessStrategy =
399
- session .getFactory ().getCustomEntityDirtinessStrategy ();
400
- return customEntityDirtinessStrategy .canDirtyCheck ( entity , getPersister (), session )
401
- && !customEntityDirtinessStrategy .isDirty ( entity , getPersister (), session );
396
+ else if ( isHibernateProxy ( entity ) ) {
397
+ uninitializedProxy = extractLazyInitializer ( entity ).isUninitialized ();
402
398
}
399
+ else {
400
+ uninitializedProxy = false ;
401
+ }
402
+ // we never have to check an uninitialized proxy
403
+ return uninitializedProxy
404
+ || !persister .hasCollections ()
405
+ && !persister .hasMutableProperties ()
406
+ && !asSelfDirtinessTracker ( entity ).$$_hibernate_hasDirtyAttributes ()
407
+ && asManagedEntity ( entity ).$$_hibernate_useTracker ();
403
408
}
404
409
405
410
@ Override
0 commit comments