-
Notifications
You must be signed in to change notification settings - Fork 616
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for uniqueness #36
Comments
Hi Rajaram, I'll have a look into your approach. Could you actually fork the project and issue a pull-request? That makes it easier to see everything in one place. My idea was to add @indexed(type = UNIQUE) to properties but that would have some more widespread implications (e.g vetoing property changes) and might be too much complexity. The other idea was just to have a small wrapper around UniqueFactory in Neo4jTemplate for creating unique entities (similar to createNodeAs()) |
I have a problem using @indexed(unique=true). |
How did you acquire the first (unique) user when adding it to the second user as a friend? Can you share the code? |
I am developing a facebook application and when i login i get the json with all my data from facebook, including friends [{id:1124332123, name:John Smith},{id:5632454536,name: Anna Molly}], so i only have refference to their id and name but if they allready exist in the graph, they have many other properties. so when i refference them i add a new User object with only the unique id from facebook in the Set friends; of my user |
for(int k = 0; k < me.getJsonObject("friends").getJsonArray("data").length(); k++) { this way, if one of them allready exists will be replaced by a node with only the fbid property. |
and i can't mannually check for their existance because some users have thousands of friends and likes and other things in their jsons and it would take too long and would use many resources...i think |
The problem is - as you save the new User and its other properties are null those will override the existing ones, so for those users it might be sensible to really use the template.getOrCreateNode() And try to change your code so that it doesn't do the get's on the json all the time, store
in a variable. |
Thank you for your reply!
and where should i use the getOrCreateNode(..)? for(int k = 0; k < friends.length(); k++) { String fbId = friends.getJsonObject(k).getString("id"); User friend = getOrCreateNode(....); //here? } |
You might have to call template.postEntityCreation(node, User.class) after creating it. |
Yep! That did the trick. Thank you very much for your help. I think you guys are doing a great job with sdn and neo4j! |
… Added test to prove spatial geom nodes are now removed
Would like to add support for uniqueness using the UniqueFactory functionality in Neo4j 1.6. An approach is to add a Unique annotation to a field in a node entity which will create the node using the UniqueFactory in EntityStateHandler and NodeEntityState - as implemented in these 3 commits:
rgan@492929e
rgan@ccd230b
rgan@8fef84e
Do you see issues with this approach?
The text was updated successfully, but these errors were encountered: