2

How can i retrieve in Spring a List from this query

MATCH (n) WITH DISTINCT LABELS (n) as labels RETURN labels

Which doesn't create a node, but return just some strings referred to all different labels in my neo4j database?

Luanne
  • 19,145
  • 1
  • 39
  • 51

1 Answers1

5

If you use the org.neo4j.ogm.session.Session.query method that returns a org.neo4j.ogm.model.Result, you should have a column called labels that contains the labels returned by your query.

You can also use @Query in your repository like this:

  @Query("MATCH (n) WITH DISTINCT LABELS (n) as labels RETURN labels")
  List<String> findLabels();
Luanne
  • 19,145
  • 1
  • 39
  • 51
  • Thanks Luanne, I'll try this tomorrow –  Oct 04 '16 at 22:01
  • Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Thu Oct 13 17:39:17 CEST 2016 There was an unexpected error (type=Internal Server Error, status=500). com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "meta" (class org.neo4j.ogm.session.result.RowModelResult), not marked as ignorable (one known property: "row"]) at [Source: {"row":[["Employee"]],"meta":[null]}; line: 1, column: 31] (through reference chain: org.neo4j.ogm.session.result.RowModelResult["meta"]) –  Oct 13 '16 at 15:40