Package org.springframework.data.neo4j.support.query

Examples of org.springframework.data.neo4j.support.query.CypherQueryEngine


        return Traversal.description();
    }

    public <T> QueryEngine<T> queryEngineFor(QueryType type) {
        switch (type) {
            case Cypher:  return (QueryEngine<T>)new CypherQueryEngine(delegate, createResultConverter());
            case Gremlin: return (QueryEngine<T>) new GremlinQueryEngine(delegate);
        }
        throw new IllegalArgumentException("Unknown Query Engine Type "+type);
    }
View Full Code Here


        assertEquals(testTeam.sdg.getName(),groups.iterator().next().getName());
    }

    @Test @Transactional
    public void testQueryEngineForCypher() throws Exception {
        final CypherQueryEngine engine = neo4jOperations.queryEngineFor();
        final Person result = engine.query("start n=node({self}) return n", map("self", testTeam.michael.getId())).to(Person.class).single();
        assertEquals(testTeam.michael.getId(), result.getId());
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    @Override
    public Page<T> query(Execute query, Execute countQuery, Map<String, Object> params, Pageable page) {
        final Execute limitedQuery = ((Skip)query).skip(page.getOffset()).limit(page.getPageSize());
        CypherQueryEngine engine = template.queryEngineFor();
        Page result = engine.query(limitedQuery.toString(), params).to(clazz).as(Page.class);
        if (countQuery == null) {
            return result;
        }
        Long count = engine.query(countQuery.toString(), params).to(Long.class).singleOrNull();
        if (count==null) return result;
        return new PageImpl<T>(result.getContent(),page, count);
    }
View Full Code Here

    public static Node obtainReferenceNode(GraphDatabase db, String name) {
        return executeQuery(db, name, "MERGE (ref:ReferenceNode {name:{name}}) RETURN ref");
    }

    private static Node executeQuery(GraphDatabase db, String name, String query) {
        CypherQueryEngine engine = db.queryEngine();
        return engine.query(query,map("name", name)).to(Node.class).singleOrNull();
    }
View Full Code Here

TOP

Related Classes of org.springframework.data.neo4j.support.query.CypherQueryEngine

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.