@NodeEntity
public class Agency {
@GraphId
private Long id;
private String name
@Query("start n=node({self}) match n<-[:BELONG_TO]-(u:User) return count(u);")
private int numberOfEmployees;
}
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@QueryAnnotation
@Documented
public @interface Query {
Hi
@Query is currently only available on Repository methods. We discussed adding it to domain entity classes, and decided to defer that for M1, primarily for complexity/performance reasons. (Imagine a node entity with 10 @Query annotations and then a request to load a couple of hundred of those entities in one go). In the worst case (naive) scenario, a single request end up hitting the database thousands of times.
As an alternative, you can do this:
```
public class Agency {
@Relationship(type="BELONG_TO", direction=Relationship.INCOMING)
private List<Employee> employees
private int numberOfEmployees() {
return employees.size();
}
}
```
By default, when you load an entity, its immediate neighbours in the graph will be loaded as well, so you get the Employees information when you make a request for an Agency.
On behalf of Vince Bickers.
--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.