Search in sources :

Example 1 with RelationshipDeleteStatements

use of org.neo4j.ogm.session.request.strategy.impl.RelationshipDeleteStatements 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

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