use of org.neo4j.kernel.api.exceptions.schema.UnableToValidateConstraintException in project neo4j by neo4j.
the class ConstraintEnforcingEntityOperations method validateNoExistingNodeWithExactValues.
private void validateNoExistingNodeWithExactValues(KernelStatement state, UniquenessConstraintDescriptor constraint, ExactPredicate[] propertyValues, long modifiedNode) throws ConstraintValidationException {
try {
NewIndexDescriptor index = constraint.ownedIndexDescriptor();
assertIndexOnline(state, index);
int labelId = index.schema().getLabelId();
state.locks().optimistic().acquireExclusive(state.lockTracer(), INDEX_ENTRY, indexEntryResourceId(labelId, propertyValues));
long existing = entityReadOperations.nodeGetFromUniqueIndexSeek(state, index, propertyValues);
if (existing != NO_SUCH_NODE && existing != modifiedNode) {
throw new UniquePropertyValueValidationException(constraint, VALIDATION, new IndexEntryConflictException(existing, NO_SUCH_NODE, OrderedPropertyValues.of(propertyValues)));
}
} catch (IndexNotFoundKernelException | IndexBrokenKernelException | IndexNotApplicableKernelException e) {
throw new UnableToValidateConstraintException(constraint, e);
}
}
Aggregations