use of org.neo4j.ogm.session.request.strategy.impl.NodeDeleteStatements 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.session.request.strategy.impl.NodeDeleteStatements in project neo4j-ogm by neo4j.
the class DeleteDelegate method delete.
public <T> Object delete(Class<T> clazz, Iterable<Filter> filters, boolean listResults) {
ClassInfo classInfo = session.metaData().classInfo(clazz.getSimpleName());
if (classInfo != null) {
resolvePropertyAnnotations(clazz, filters);
CypherQuery query;
if (classInfo.isRelationshipEntity()) {
query = new RelationshipDeleteStatements().deleteAndList(classInfo.neo4jName(), filters);
} else {
query = new NodeDeleteStatements().deleteAndList(classInfo.neo4jName(), filters);
}
if (listResults) {
return list(query, classInfo.isRelationshipEntity());
}
return count(query, classInfo.isRelationshipEntity());
}
throw new RuntimeException(clazz.getName() + " is not a persistable class");
}
Aggregations