// we assume there were no changes to natural id during detachment for now, that is validated later
// during flush.
return;
}
final NaturalIdHelper naturalIdHelper = session.getPersistenceContext().getNaturalIdHelper();
final Serializable id = getIdentifier( entity, session );
// for reattachment of mutable natural-ids, we absolutely positively have to grab the snapshot from the
// database, because we have no other way to know if the state changed while detached.
final Object[] naturalIdSnapshot;
final Object[] entitySnapshot = session.getPersistenceContext().getDatabaseSnapshot( id, this );
if ( entitySnapshot == StatefulPersistenceContext.NO_ROW ) {
naturalIdSnapshot = null;
}
else {
naturalIdSnapshot = naturalIdHelper.extractNaturalIdValues( entitySnapshot, this );
}
naturalIdHelper.removeSharedNaturalIdCrossReference( this, id, naturalIdSnapshot );
naturalIdHelper.manageLocalNaturalIdCrossReference(
this,
id,
naturalIdHelper.extractNaturalIdValues( entity, this ),
naturalIdSnapshot,
CachedNaturalIdValueSource.UPDATE
);
}