use of org.hibernate.CustomEntityDirtinessStrategy in project hibernate-orm by hibernate.
the class AbstractEntityEntry method isUnequivocallyNonDirty.
@SuppressWarnings({ "SimplifiableIfStatement" })
private boolean isUnequivocallyNonDirty(Object entity) {
if (entity instanceof SelfDirtinessTracker) {
boolean uninitializedProxy = false;
if (entity instanceof PersistentAttributeInterceptable) {
final PersistentAttributeInterceptable interceptable = (PersistentAttributeInterceptable) entity;
final PersistentAttributeInterceptor interceptor = interceptable.$$_hibernate_getInterceptor();
if (interceptor instanceof EnhancementAsProxyLazinessInterceptor) {
EnhancementAsProxyLazinessInterceptor enhancementAsProxyLazinessInterceptor = (EnhancementAsProxyLazinessInterceptor) interceptor;
return !enhancementAsProxyLazinessInterceptor.hasWrittenFieldNames();
}
} else if (entity instanceof HibernateProxy) {
uninitializedProxy = ((HibernateProxy) entity).getHibernateLazyInitializer().isUninitialized();
}
// we never have to check an uninitialized proxy
return uninitializedProxy || !persister.hasCollections() && !persister.hasMutableProperties() && !((SelfDirtinessTracker) entity).$$_hibernate_hasDirtyAttributes();
}
if (entity instanceof PersistentAttributeInterceptable) {
final PersistentAttributeInterceptable interceptable = (PersistentAttributeInterceptable) entity;
final PersistentAttributeInterceptor interceptor = interceptable.$$_hibernate_getInterceptor();
if (interceptor instanceof EnhancementAsProxyLazinessInterceptor) {
// we never have to check an uninitialized proxy
return true;
}
}
final CustomEntityDirtinessStrategy customEntityDirtinessStrategy = getPersistenceContext().getSession().getFactory().getCustomEntityDirtinessStrategy();
if (customEntityDirtinessStrategy.canDirtyCheck(entity, getPersister(), (Session) getPersistenceContext().getSession())) {
return !customEntityDirtinessStrategy.isDirty(entity, getPersister(), (Session) getPersistenceContext().getSession());
}
if (getPersister().hasMutableProperties()) {
return false;
}
return false;
}
Aggregations