use of org.neo4j.ogm.cypher.query.DefaultRowModelRequest in project neo4j-ogm by neo4j.
the class DeleteDelegate method purgeDatabase.
public void purgeDatabase() {
Statement stmt = new NodeDeleteStatements().deleteAll();
RowModelRequest query = new DefaultRowModelRequest(stmt.getStatement(), stmt.getParameters());
session.doInTransaction(() -> {
session.requestHandler().execute(query).close();
}, Transaction.Type.READ_WRITE);
session.context().clear();
}
use of org.neo4j.ogm.cypher.query.DefaultRowModelRequest in project neo4j-ogm by neo4j.
the class CountStatements method countNodes.
@Override
public CypherQuery countNodes(String label, Iterable<Filter> filters) {
FilteredQuery query = FilteredQueryBuilder.buildNodeQuery(label, filters);
query.setReturnClause(" RETURN COUNT(n)");
return new DefaultRowModelRequest(query.statement(), query.parameters());
}
use of org.neo4j.ogm.cypher.query.DefaultRowModelRequest in project neo4j-ogm by neo4j.
the class RelationshipDeleteStatements method delete.
@Override
public CypherQuery delete(Long id, Object object, ClassInfo classInfo) {
FieldInfo versionField = classInfo.getVersionField();
Long version = (Long) versionField.read(object);
OptimisticLockingConfig optimisticLockingConfig = new OptimisticLockingConfig(1, classInfo.staticLabels().toArray(new String[] {}), versionField.property());
Map<String, Object> params = new HashMap<>();
params.put("id", id);
params.put("version", version);
params.put("type", "rel");
return new DefaultRowModelRequest("MATCH (n)-[r0]->() " + " WHERE ID(r0) = $id AND r0.`" + versionField.property() + "` = $version " + "SET " + " r0.`" + versionField.property() + "` = r0.`" + versionField.property() + "` + 1 " + "WITH r0 " + " WHERE r0.`" + versionField.property() + "` = $version + 1 " + "DELETE r0 " + // Use DISTINCT because node may have multiple relationships
"RETURN DISTINCT ID(r0) AS id", params, optimisticLockingConfig);
}
use of org.neo4j.ogm.cypher.query.DefaultRowModelRequest in project neo4j-ogm by neo4j.
the class RelationshipDeleteStatements method delete.
@Override
public CypherQuery delete(String type, Iterable<Filter> filters) {
FilteredQuery query = FilteredQueryBuilder.buildRelationshipQuery(type, filters);
query.setReturnClause(" DELETE r0");
return new DefaultRowModelRequest(query.statement(), query.parameters());
}
use of org.neo4j.ogm.cypher.query.DefaultRowModelRequest in project neo4j-ogm by neo4j.
the class CountStatements method countEdges.
@Override
public CypherQuery countEdges(String type, Iterable<Filter> filters) {
FilteredQuery query = FilteredQueryBuilder.buildRelationshipQuery(type, filters);
query.setReturnClause(" RETURN COUNT(r0)");
return new DefaultRowModelRequest(query.statement(), query.parameters());
}
Aggregations