Serializable id = persister.getIdentifier( entity, source.getEntityMode() );
if ( id == null ) {
throw new TransientObjectException( "instance with null id passed to replicate()" );
}
final ReplicationMode replicationMode = event.getReplicationMode();
final Object oldVersion;
if ( replicationMode == ReplicationMode.EXCEPTION ) {
//always do an INSERT, and let it fail by constraint violation
oldVersion = null;
}
else {
//what is the version on the database?
oldVersion = persister.getCurrentVersion( id, source );
}
if ( oldVersion != null ) {
if ( log.isTraceEnabled() ) {
log.trace(
"found existing row for " +
MessageHelper.infoString( persister, id, source.getFactory() )
);
}
/// HHH-2378
final Object realOldVersion = persister.isVersioned() ? oldVersion : null;
boolean canReplicate = replicationMode.shouldOverwriteCurrentVersion(
entity,
realOldVersion,
persister.getVersion( entity, source.getEntityMode() ),
persister.getVersionType()
);