-
Oct 21st, 2012, 11:11 PM
#1
[neo4j] Unique key constraint: Applies on root node only or the child nodes as well ?
After doing couple of testing it seems like, Unique field is enforced only in the nodeEntity where it is declared.
It does not guarantee the other member variables (nodeEntities) of the nodeEntity to be unique.
For example following are the two NodeEntity classes, where B is used as member variable in A.
@NodeEntity
public class B(
@Indexed(indexName="i1")
private String m_BName;
. . .
}
@NodeEntity
public class A(
@Indexed(indexName="i2", unique=true)
private String m_AName;
private Set<B> m_Bs;
. . .
}
Now I do the following
A a1 = new A("nameA");
A.persist();
A a2 = new A("nameA");
A.persist();
After executing the above node A does not get created again because of the unique constraint on m_AName field. But it creates a 2nd set of B entities (Set<B> is member variable of A) when persisting A for the second time.
I saw if I declare one of the fields (e.g., m_BName) be unique in B, another set of B's does not get recreated while calling A.persist() for the second time.
The behavior I am expecting here, if the main entity (e.g., A) fails to match the unique constraint, then none of the nodes under it (e.g., B) should be created, regardless the any field in the containing objects are unique or not. Should not that be a normal behavior ? Please suggest.
I also found that SDN supports at most field to be unique. Is there any plan to increase that later ?
Thanks in advance
Faisal
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules