[Neo4j] Clear graph (delete all nodes and relations)

Mattias Persson mattias at neotechnology.com
Wed Mar 2 12:16:24 CET 2011


2011/3/2 Craig Taverner <craig at amanzi.com>:
> Is this not because blueprints does not respect the neo4j reference node,
> and so deletes it (really clears the graph). Is there a way to create the
> reference node again? Perhaps as simple as db.createNode(), and the first
> will be node 0?

I believe Tinkerpop not caring about the reference node is the reason, yes.
>
> On Wed, Mar 2, 2011 at 12:08 PM, Peter Neubauer <
> peter.neubauer at neotechnology.com> wrote:
>
>> Mmh,
>> have you committed the transaction after your clear, and How are you
>> trying to create the Relationship? It seems you are trying to use Node
>> 0 for it, which you have deleted before? In that case, you need to add
>> a new node and use that as the starting point for your relationship?
>>
>> Cheers,
>>
>> /peter neubauer
>>
>> GTalk:      neubauer.peter
>> Skype       peter.neubauer
>> Phone       +46 704 106975
>> LinkedIn   http://www.linkedin.com/in/neubauer
>> Twitter      http://twitter.com/peterneubauer
>>
>> http://www.neo4j.org               - Your high performance graph database.
>> http://startupbootcamp.org/    - Öresund - Innovation happens HERE.
>> http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing party.
>>
>>
>>
>> On Wed, Mar 2, 2011 at 11:44 AM, Alfredas Chmieliauskas
>> <al.fredas at gmail.com> wrote:
>> > Dear all,
>> >
>> > a crazy primitive question. How do I clear a graph (without doing rm -f)
>> ?
>> > If I delete all the nodes and relationships or use blueprints
>> > graph.clear() I get a weird error later when adding new nodes:
>> >
>> > Caused by: java.lang.IllegalStateException: First node[0] is deleted
>> > and cannot be used to create a relationship
>> >        at
>> org.neo4j.kernel.impl.nioneo.xa.WriteTransaction.relationshipCreate(WriteTransaction.java:1475)
>> >        at
>> org.neo4j.kernel.impl.nioneo.xa.NeoStoreXaConnection$RelationshipEventConsumerImpl.createRelationship(NeoStoreXaConnection.java:257)
>> >        at
>> org.neo4j.kernel.impl.nioneo.xa.NioNeoDbPersistenceSource$NioNeoDbResourceConnection.relationshipCreate(NioNeoDbPersistenceSource.java:371)
>> >        at
>> org.neo4j.kernel.impl.persistence.PersistenceManager.relationshipCreate(PersistenceManager.java:154)
>> >        at
>> org.neo4j.kernel.impl.core.NodeManager.createRelationship(NodeManager.java:310)
>> >        at
>> org.neo4j.kernel.impl.core.NodeImpl.createRelationshipTo(NodeImpl.java:388)
>> >        at
>> org.neo4j.kernel.impl.core.NodeProxy.createRelationshipTo(NodeProxy.java:187)
>> >        at
>> org.neo4j.util.GraphDatabaseUtil.getOrCreateSingleOtherNode(GraphDatabaseUtil.java:137)
>> >        at
>> org.neo4j.util.GraphDatabaseUtil.getOrCreateSubReferenceNode(GraphDatabaseUtil.java:167)
>> >        at
>> org.neo4j.util.GraphDatabaseUtil.getOrCreateSubReferenceNode(GraphDatabaseUtil.java:150)
>> >        at
>> org.springframework.data.graph.neo4j.support.GraphDatabaseContext.getOrCreateSubReferenceNode(GraphDatabaseContext.java:275)
>> >        at
>> org.springframework.data.graph.neo4j.support.SubReferenceNodeTypeStrategy.obtainSubreferenceNode(SubReferenceNodeTypeStrategy.java:167)
>> >        at
>> org.springframework.data.graph.neo4j.support.SubReferenceNodeTypeStrategy.postEntityCreation(SubReferenceNodeTypeStrategy.java:66)
>> >        at
>> org.springframework.data.graph.neo4j.support.GraphDatabaseContext.postEntityCreation(GraphDatabaseContext.java:219)
>> >        at
>> org.springframework.data.graph.neo4j.fieldaccess.NodeEntityStateAccessors.createAndAssignState(NodeEntityStateAccessors.java:54)
>> >        at
>> org.springframework.data.graph.neo4j.fieldaccess.DetachableEntityStateAccessors.createAndAssignState(DetachableEntityStateAccessors.java:113)
>> >        at
>> org.springframework.data.graph.neo4j.support.node.Neo4jNodeBacking.ajc$before$org_springframework_data_graph_neo4j_support_node_Neo4jNodeBacking$1$74591ff9(Neo4jNodeBacking.aj:84)
>> >
>> > Also I'm using Spring Data Graph to create new nodes and relations.
>> >
>> > Any ideas?
>> >
>> > Alfredas
>> > _______________________________________________
>> > Neo4j mailing list
>> > User at lists.neo4j.org
>> > https://lists.neo4j.org/mailman/listinfo/user
>> >
>> _______________________________________________
>> Neo4j mailing list
>> User at lists.neo4j.org
>> https://lists.neo4j.org/mailman/listinfo/user
>>
> _______________________________________________
> Neo4j mailing list
> User at lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Mattias Persson, [mattias at neotechnology.com]
Hacker, Neo Technology
www.neotechnology.com


More information about the User mailing list