@Override
public ODocument checkEntry(final OIdentifiable iRecord, final Object iKey) {
// CHECK IF ALREADY EXISTS IN TX
String storageType = database.getStorage().getType();
if (!database.getTransaction().isActive()) {
final OIdentifiable previousRecord = get(iKey);
if (previousRecord != null && !previousRecord.equals(iRecord)) {
final ODocument metadata = getMetadata();
final boolean mergeSameKey = metadata != null && (Boolean) metadata.field(OIndex.MERGE_KEYS);
if (mergeSameKey) {
return (ODocument) previousRecord.getRecord();
} else
throw new ORecordDuplicatedException(String.format(
"Cannot index record %s: found duplicated key '%s' in index '%s' previously assigned to the record %s", iRecord,
iKey, getName(), previousRecord), previousRecord.getIdentity());
}
return super.checkEntry(iRecord, iKey);
}
return null;
}