Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-06-2021 09:29 AM
I have simple project that has to connect nodes Train and Station. Connection between them is called STOPS. When I'm trying to execute query with this relationship I get an empty array. But when I execute this query in Neo4j Desktop I get expected result.
Here is my code:
public interface TrainRepository extends Neo4jRepository<Train, Long> {
@Query("MATCH (u)<-[r:STOPS]-(m:Station) RETURN u,collect(r),collect(m)")
Collection<Train> getAllTrains();
}
@NodeEntity
public class Train {
@Id
@GeneratedValue
private Long id;
private Integer number;
private Integer number_of_carriages;
public List<Station> getStations() {
System.out.println(stations);
return stations;
}
public void setStations(List<Station> stations) {
this.stations = stations;
}
@Relationship(type = "STOPS", direction = Relationship.INCOMING)
private List<Station> stations;
...
}
01-07-2021 04:23 AM
Just for clarification: You get an empty Train
collection or Station
collection within a returned Train
?
All the sessions of the conference are now available online