admin管理员组

文章数量:1180433

Parent class

@Node
@NoArgsConstructor
@AllArgsConstructor
public class Dish {
  @Id
  private String dishName;
  @Relationship(type = "CONTAINS", direction = Relationship.Direction.OUTGOING)
  private List<Ingredient> ingredients;
  private String recipeUrl;
  private String cuisine; // New field for cuisine
  private String dishType; // New field for dish type

  // Getters and Setters for all fields

Child class

@Getter
@Setter
public class Ingredient {
  @Id
  private String nameInEnglish;
  private String nameInHindi;
  private String nameInGerman;

mapping in neo4j

MATCH (d:Dish {dishName: 'Paneer Butter Masala'}),
      (i1:Ingredient {nameInEnglish: 'Paneer'}),
      (i2:Ingredient {nameInEnglish: 'Butter'}),
      (i3:Ingredient {nameInEnglish: 'Tomato'})
CREATE (d)-[:CONTAINS]->(i1),
       (d)-[:CONTAINS]->(i2),
       (d)-[:CONTAINS]->(i3);

neo4j browser returns one dish with one ingredient

    MATCH (d:Dish)-[:CONTAINS]->(i:Ingredient)
    WHERE i.nameInEnglish = "Paneer"
    RETURN d,collect(i) as ingredients

but Java response has 1 dish with an ingredient arraylist always empty.

本文标签: Cannot fetch child entity (contains) in springdataneo4jStack Overflow