use of org.neo4j.kernel.api.exceptions.RelationshipTypeIdNotFoundKernelException in project neo4j by neo4j.
the class NodeProxy method createRelationshipTo.
@Override
public Relationship createRelationshipTo(Node otherNode, RelationshipType type) {
if (otherNode == null) {
throw new IllegalArgumentException("Other node is null.");
}
//}
try (Statement statement = actions.statement()) {
int relationshipTypeId = statement.tokenWriteOperations().relationshipTypeGetOrCreateForName(type.name());
long relationshipId = statement.dataWriteOperations().relationshipCreate(relationshipTypeId, nodeId, otherNode.getId());
return actions.newRelationshipProxy(relationshipId, nodeId, relationshipTypeId, otherNode.getId());
} catch (IllegalTokenNameException | RelationshipTypeIdNotFoundKernelException e) {
throw new IllegalArgumentException(e);
} catch (EntityNotFoundException e) {
throw new NotFoundException("Node[" + e.entityId() + "] is deleted and cannot be used to create a relationship");
} catch (InvalidTransactionTypeKernelException e) {
throw new ConstraintViolationException(e.getMessage(), e);
}
}
Aggregations