Spring Data Neo4J @Indexed(unique = true) not working

前端 未结 2 415
被撕碎了的回忆
被撕碎了的回忆 2021-01-18 07:11

I\'m new to Neo4J and I have, probably an easy question.

There\'re NodeEntitys in my application, a property (name) is annotated with @Indexed(unique = true) to achi

相关标签:
2条回答
  • 2021-01-18 07:19

    I walked into the same trap... as long as you create new entities, you will not see the exception - the last save()-action wins the battle.

    Unfortunately, the DataIntegrityViolationException will be raised only in case of update an existing entity!

    A detailed description of that behaviour can be found here: http://static.springsource.org/spring-data/data-graph/snapshot-site/reference/html/#d5e1035

    0 讨论(0)
  • 2021-01-18 07:33

    If you are using SDN 3.2.0+ use the failOnDuplicate attribute:

    public class Role extends BaseEntity
    {
        @Indexed(unique = true, failOnDuplicate = true)
        private String name;
        ...
    }
    
    0 讨论(0)
提交回复
热议问题