Results 1 to 2 of 2

Thread: [neo4j] Exception persisting nodes with duplicate unique keys

Hybrid View

  1. #1
    Join Date
    Oct 2012
    Posts
    10

    Default [neo4j] Exception persisting nodes with duplicate unique keys

    Hi there,
    I am trying to use the unique entity support of Spring Data Neo4j. I have annotated a field with @Indexed(unique=true)

    I found that this is working, since no duplicate nodes are being created in the database. But I cannot catch the exception while persisting it.
    I want to do something like the following

    try
    {
    u1.persist();
    }
    catch (SomeException e)
    {
    System.out.println(e.getMessage());
    }

    Does anybody have any idea, how to do this ?

    Thanks
    Faisal

  2. #2
    Join Date
    Jan 2011
    Location
    Dresden, Germany
    Posts
    525

    Default

    Neo4j's unique indexes work like that, if the entity is already in the graph you get it back, otherwise it is created for you.

    It is rather a "getOrCreate()" operation. Not so much we can do in the SDN world about it.

    You can compare the object on your side but they should be equal anyway.

    Michael

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •