Announcement Announcement Module
Collapse
No announcement yet.
Neo4J - Problem persisting a object with multiple fields anotated with @Indexed(true) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Neo4J - Problem persisting a object with multiple fields anotated with @Indexed(true)

    Hi,

    I have a @NodeEntity Class with multiple fields annotated with "@Indexed(unique = true)" (see below). I'd like these fields to be unique.

    When I try to persist the Object with GraphRepository, I get the following exception:
    Code:
    Exception in thread "main" org.springframework.data.mapping.model.MappingException: Duplicate unique property userId, username has already been defined. Only one unique property is allowed per type
    if I have single field with this annotation there is no exceptions, (only for multiple fields).
    What is causing this ? How do i make these fields unique?

    Code:
           private int userId;
    	@Indexed(unique = true) private String name;
    	@Indexed(unique = true) private String username;
    	@Indexed(unique = true) private String emailAddress;

  • #2
    There is a limitation in Neo4j that only allows unique indexes for one field. So you could try to create an artificial field that concatenates the contents of all of these fields and is used as unique index.

    Comment

    Working...
    X