Announcement Announcement Module
No announcement yet.
Issue with Neo4jTemplate Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Issue with Neo4jTemplate

    Hi All,

    i have a issue with Neo4jTemplate,

    let me explain about my project,

    i'm using Mavenwebproject,SpringMVC,SpringData,Neo4jServer and GraphDatabase

    i was configured my GraphDatabase in Spring applicationContext as like below

    <neo4j:config storeDirectory="C:/neo4j-enterprise-1.6/data/crmpp_db"/>

    now in my Controller i initializing Neo4jTemplate like below

    two ways i am trying to create node and relationshiptype with Neo4jTemplate

    public Neo4jTemplate neo4jTemplate;

    First Way is below :

    Map<String, Object> mapContact = new HashMap<String, Object>();
    mapContact.put("firstName", "James");
    mapContact.put("lastName", "Gowsling");
    Contact node = neo4jTemplate.createNodeAs(Contact.class, mapContact);
    System.out.println("NOde - id - "+node.getFirstName());

    Second way is below:

    i am trying to create Node and RelationshipType in my Controller.
    GraphDatabaseService service = neo4jTemplate.getGraphDatabaseService();
    Node node = service.getReferenceNode();
    Node node1 = neo4jTemplate.createNode();
    node1.setProperty("FirstName", "James");
    node1.setProperty("LastName", "Gowsling");
    RelationshipType KNOWS = DynamicRelationshipType.withName("TEST");
    boolean flag = neo4jTemplate.transactionIsRunning();

    This way i am created Node and RelationshipType,

    so upto now it is working fine, the main problem is when run the program, it is completed successfully

    but i am unable to see in the database, it is not created any node in database,

    with two ways i didn't created node in database.
    could you please help where i am missing.

  • #2
    How do you look into the database?

    Can you show that code too, or at least what tool you use to check for it.


    • #3
      Hi Michael

      i am checking in two ways :

      opening Neo4j server in browser and checking in browser option and second one looking through neoclipse


      • #4
        Are you using this code perhaps in a test with Spring's JunitTestRunner? Then the @Transactional annotations will cause your changes to be rolled back after the test.