There is no replacement for the QueryResult
in combination with repositories. Those repositories work strictly by the rules of the modeled domain classes.
For your use-case, you could for example do following:
public class DeviceNode {
// id etc.
@Relationship("CUSTOMER")
private List<DeviceNode> relatedNodes;
}
and a query like
MATCH (a:DeviceNode)-[r:CUSTOMER*]->(b:DeviceNode)
where b.deviceId={deviceId}
return a, collect(r), collect(b)
This will create a mapped chain of DeviceNodes
which seems like an even better representation of the graph in the application.
If you strictly want to stick with a looks-like-QueryResult, more information can be found here:
opened 07:03AM - 15 Jun 21 UTC
closed 08:31AM - 15 Jun 21 UTC
status: waiting-for-triage
I have a class with the following structure:
```
@NoArgsConstructor
@Setter…
@Getter
@Node
public class Person {
@Id
@GeneratedValue(GeneratedValue.UUIDGenerator.class)
private UUID id;
@Property
private String name;
@Property
private String family;
@Property
private int age;
public Person(String name, String family, int age) {
this.name = name;
this.family = family;
this.age = age;
}
}
```
I want to do a custom query like the following query:
`MATCH (n:Person) return count(n) as count, n `
I did this query using the neo4jClient and neo4jTemplate in different ways (mentioned below):
```
template.save(new Person("Reza" + new Random(System.currentTimeMillis()).nextInt(), "Mahdavi", 22));
// 1-
List<Person> result_1 = template.find(Person.class).matching("Match(n:Person) return count(n) as count,n").all();
// 2-
Collection<Person> result_2 = client.query("Match(n:Person) return count(n) as count,n").fetchAs(Person.class).all();
// 3-
Collection<Map<String, Object>> result_3 = client.query("Match(n:Person) return count(n) as count,n").fetch().all();
```
Query 1 return a List of Persons without count record.
Query 2 throw an exception
Query 3 return a list of maps that map values are InternalNode not Person. in fact, the problem is that Person nodes are returned as InternalNodes, not Person. As a result, we need to manually map the InternalNodes to the domain model objects.
This is while in the Neo4j-ogm; The output of the session.query("") was a QueryResultModel whose result field was one list of maps that map values were Person.
How do I make a custom query that returns InternalNodes automatically mapped to the domain model objects؟
opened 01:23PM - 06 May 21 UTC
closed 03:28PM - 06 May 21 UTC
type: enhancement
Since we do not officially support this, I would call this an enhancement instea… d of a bug fix ;)
Given that we want to map something like
```
MATCH (a:DatabaseObject{dbId:$dbId})-[r:output]->(m:PhysicalEntity) RETURN m, r.stoichiometry as n
```
the mapping mechanism will create a `Map` that will only contain the identifier and the node description of the template / repository. If this node description is an (abstract) parent class, we will then lose the information about the concrete type coming from the node's label.
Hi, I'm new to Neo4j! I'm currently working on a simple REST API but I cannot seem to figure out how to return both nodes and relations in a single endpoint.
My design is super simple. I have a bunch of different resource nodes [CLIENT, SERVER, DB] (which all inherit from RESOURCE) and a PROJECT node that connects them. The resource nodes have connections between them and every resource connects to exactly one Project. An example from the Neo4j Browser is attached (this is my entire DB right no…
opened 01:54PM - 11 Mar 21 UTC
closed 06:52AM - 12 Mar 21 UTC
status: waiting-for-triage
In Spring Data Neo4j 6.0.5 I can't find @Queryresult. How can I map a result ret… urned from neo4j.