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

梦想的初衷 提交于 2019-12-01 17:31:16

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

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;
    ...
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!