Search in sources :

Example 1 with NodeDeleteStatements

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();
}
Also used : Statement(org.neo4j.ogm.request.Statement) RowModelRequest(org.neo4j.ogm.request.RowModelRequest) DefaultRowModelRequest(org.neo4j.ogm.cypher.query.DefaultRowModelRequest) NodeDeleteStatements(org.neo4j.ogm.session.request.strategy.impl.NodeDeleteStatements) DefaultRowModelRequest(org.neo4j.ogm.cypher.query.DefaultRowModelRequest)

Example 2 with NodeDeleteStatements

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");
}
Also used : CypherQuery(org.neo4j.ogm.cypher.query.CypherQuery) RelationshipDeleteStatements(org.neo4j.ogm.session.request.strategy.impl.RelationshipDeleteStatements) NodeDeleteStatements(org.neo4j.ogm.session.request.strategy.impl.NodeDeleteStatements) ClassInfo(org.neo4j.ogm.metadata.ClassInfo)

Aggregations

NodeDeleteStatements (org.neo4j.ogm.session.request.strategy.impl.NodeDeleteStatements)2 CypherQuery (org.neo4j.ogm.cypher.query.CypherQuery)1 DefaultRowModelRequest (org.neo4j.ogm.cypher.query.DefaultRowModelRequest)1 ClassInfo (org.neo4j.ogm.metadata.ClassInfo)1 RowModelRequest (org.neo4j.ogm.request.RowModelRequest)1 Statement (org.neo4j.ogm.request.Statement)1 RelationshipDeleteStatements (org.neo4j.ogm.session.request.strategy.impl.RelationshipDeleteStatements)1