Search in sources :

Example 1 with RelationshipProxy

use of org.neo4j.kernel.impl.core.RelationshipProxy in project neo4j by neo4j.

the class TxStateTransactionDataSnapshot method relationship.

private Relationship relationship(long relId) {
    RelationshipProxy relationship = new RelationshipProxy(relationshipActions, relId);
    if (!state.relationshipVisit(relId, relationship)) {
        // This relationship has been created or changed in this transaction
        RelationshipProxy cached = relationshipsReadFromStore.get(relId);
        if (cached != null) {
            return cached;
        }
        try {
            // Get this relationship data from the store
            store.relationshipVisit(relId, relationship);
            relationshipsReadFromStore.put(relId, relationship);
        } catch (EntityNotFoundException e) {
            throw new IllegalStateException("Getting deleted relationship data should have been covered by the tx state");
        }
    }
    return relationship;
}
Also used : RelationshipProxy(org.neo4j.kernel.impl.core.RelationshipProxy) EntityNotFoundException(org.neo4j.kernel.api.exceptions.EntityNotFoundException)

Example 2 with RelationshipProxy

use of org.neo4j.kernel.impl.core.RelationshipProxy in project neo4j by neo4j.

the class GraphDatabaseFacade method getRelationshipById.

@Override
public Relationship getRelationshipById(long id) {
    if (id < 0) {
        throw new NotFoundException(format("Relationship %d not found", id), new EntityNotFoundException(EntityType.RELATIONSHIP, id));
    }
    try (Statement statement = spi.currentStatement()) {
        try {
            RelationshipProxy relationship = new RelationshipProxy(relActions, id);
            statement.readOperations().relationshipVisit(id, relationship);
            return relationship;
        } catch (EntityNotFoundException e) {
            throw new NotFoundException(format("Relationship %d not found", id), e);
        }
    }
}
Also used : RelationshipProxy(org.neo4j.kernel.impl.core.RelationshipProxy) Statement(org.neo4j.kernel.api.Statement) NotFoundException(org.neo4j.graphdb.NotFoundException) SchemaRuleNotFoundException(org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException) EntityNotFoundException(org.neo4j.kernel.api.exceptions.EntityNotFoundException) EntityNotFoundException(org.neo4j.kernel.api.exceptions.EntityNotFoundException)

Aggregations

EntityNotFoundException (org.neo4j.kernel.api.exceptions.EntityNotFoundException)2 RelationshipProxy (org.neo4j.kernel.impl.core.RelationshipProxy)2 NotFoundException (org.neo4j.graphdb.NotFoundException)1 Statement (org.neo4j.kernel.api.Statement)1 SchemaRuleNotFoundException (org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException)1