Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6890575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:17:59+00:00 2026-05-27T06:17:59+00:00

I’m just getting started with Neo4j and running Hello World type examples. I create

  • 0

I’m just getting started with Neo4j and running “Hello World” type examples.

I create a new database and print out the number of nodes, which is 1 (since there appears to be a default node when a database is created).

I create a node and add it to the graph. The graph reports that there are now 2 nodes – OK.

I then delete the node again, and the graph reports that there is 1 node – OK.

I then shut down the database.

However, when I run the same code again (without deleting the database files). it now reports that there are 2 nodes initially. Instead of 1-2-1, I get 2-3-2. This only happens once – after the first run it always reports 2-3-2.

Why is my deleted node reappearing, but only the first time?

Code below:

package com.foo.neo.example;

import org.neo4j.graphdb.*;
import org.neo4j.kernel.EmbeddedGraphDatabase;

public class Deleting
{
    static GraphDatabaseService graphDb;

    public static void main(String[] args)
    {
        graphDb = new EmbeddedGraphDatabase("data");
        System.out.println("STARTED");

        printNodeCount();

        Node firstNode;

        Transaction tx = graphDb.beginTx();
        try
        {
            firstNode = graphDb.createNode();
            tx.success();
        }
        finally
        {
            tx.finish();
        }

        printNodeCount();

        // delete the data again
        tx = graphDb.beginTx();
        try
        {
            firstNode.delete();
            tx.success();
        }
        finally
        {
            tx.finish();
        }

        printNodeCount();
        graphDb.shutdown();
    }

    private static void printNodeCount()
    {
        long nodecount = ((EmbeddedGraphDatabase) graphDb).getConfig()
                .getGraphDbModule().getNodeManager()
                .getNumberOfIdsInUse(Node.class);
        System.out.println("Node count = " + nodecount);
    }
}

and output:

STARTED
Node count = 1
Node count = 2
Node count = 1

Second (and subsequent) runs:

STARTED
Node count = 2
Node count = 3
Node count = 2
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:18:00+00:00Added an answer on May 27, 2026 at 6:18 am

    Your code is correct.

    But getNumberOfIdsInUse() is not the number of nodes (or relationships) but the number of allocated id’s which might have unused intervals in between. Id reuse doesn’t happen automatically but has to be enabled.

    Can you try to count the nodes using graphDb.getAllNodes() and incrementing an counter, if it still reports the wrong numbers?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Specifically, suppose I start with the string string =hello \'i am \' me And
I want use html5's new tag to play a wav file (currently only supported
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.