Search in sources :

Example 1 with InvalidDepthException

use of org.neo4j.ogm.exception.core.InvalidDepthException in project neo4j-ogm by neo4j.

the class RelationshipQueryStatements method findByType.

@Override
public PagingAndSortingQuery findByType(String type, Filters parameters, int depth) {
    if (depth > 0) {
        FilteredQuery query = FilteredQueryBuilder.buildRelationshipQuery(type, parameters);
        String matchClause = query.statement() + " WITH DISTINCT(r0) as r0,startnode(r0) AS n, endnode(r0) AS m";
        String returnClause = loadClauseBuilder.build("r0", type, depth);
        return new PagingAndSortingQuery(matchClause, returnClause, query.parameters(), true, true, "r0");
    } else {
        throw new InvalidDepthException("Cannot load a relationship entity with depth 0 i.e. no start or end node");
    }
}
Also used : InvalidDepthException(org.neo4j.ogm.exception.core.InvalidDepthException) FilteredQuery(org.neo4j.ogm.session.request.FilteredQuery) PagingAndSortingQuery(org.neo4j.ogm.cypher.query.PagingAndSortingQuery)

Aggregations

PagingAndSortingQuery (org.neo4j.ogm.cypher.query.PagingAndSortingQuery)1 InvalidDepthException (org.neo4j.ogm.exception.core.InvalidDepthException)1 FilteredQuery (org.neo4j.ogm.session.request.FilteredQuery)1