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;
...
}