What is the correct way to save relationships in Spring Data Neo4J?
Date : March 29 2020, 07:55 AM
Hope that helps My mistake was that I was instantiating the class manually, therefore it was not spring managed. Adding the @Component annotation to the class and asking Spring to give me the class resolved the problem. @Component // This is the line that saved the day!
@RelationshipEntity(type="HAS_RIGHT")
public class Privilege {
@Autowired
Neo4jOperations operations;
@GraphId Long id;
@StartNode User user;
@EndNode Right right;
public Privilege() {
;;
}
public void createRelationship(User user, Right right) {
this.user = user;
this.right = right;
this.save();
}
/*** Getters and Setters ***/
}
...
@Autowired ApplicationContext applicationContext;
...
Privilege privilege = applicationContext.getBean(Privilege.class);
privilege.createRelationship(user, ADMINISTRATOR);
|
Spring data neo4j: correct way to handle relationships?
Tag : java , By : Gerhard Miller
Date : March 29 2020, 07:55 AM
Any of those help Since you want to retrieve groups for a user, and users in a group, it makes sense to set up your object model as you describe in #1 and #2. UNDIRECTED is not a good choice here because it implies that the relationship between user and group can be in any direction, and I'm guessing you don't want this in your graph model. It's good for relationships where you don't care about the direction (such as (user1)-[:FRIEND]-(user2)) but not otherwise. I'd use OUTGOING and INCOMING in either class depending on what your relationship between user and group actually is.
|
Using Neo4J Traversal API to perform traversal on Neo4J running on other machine
Tag : neo4j , By : Dmitry
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further The Traversal API can only be used if the code is colocated with the data, otherwise it would usually be awfully slow. The problem is that it's not purely declarative, since you can provide implementations of PathExpander, Evaluator, etc. instead of only using pre-defined constants. However, there are several ways of having this code colocated:
|
Neo4j count and order relationships to list of nodes
Tag : neo4j , By : nickthecook
Date : March 29 2020, 07:55 AM
I wish did fix the issue. I have a graph of people and items. The relationship is one to many (a:Person)-[:has]->(b:Item). For an input list of items, I am trying to get a list of people that have that item, ordered by who has the most items in the list. , Perhaps something like: MATCH (a:Person)-[:has]->(b:Item)
RETURN a, count(b) ORDER by count(b) DESC
|
Neo4J order by count relationships extremely slow
Tag : neo4j , By : user170635
Date : March 29 2020, 07:55 AM
|