# Cannot fetch child entity

**URL:** <https://community.neo4j.com/t/cannot-fetch-child-entity/72476>\
**Category:** Cypher\
**Tags:** spring-data-neo4j--n\
**Created:** [January 28, 2025, 10:21pm UTC](https://community.neo4j.com/t/cannot-fetch-child-entity/72476 "2025-01-28T22:21:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ankurbrdwj](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/ankurbrdwj/32/33924_2.png) [@ankurbrdwj](https://community.neo4j.com/u/ankurbrdwj)\
**Post date:** [January 28, 2025, 10:21pm UTC](https://community.neo4j.com/t/cannot-fetch-child-entity/72476/1 "2025-01-28T22:21:25Z")

</div>

0

Parent class

```auto
@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

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

```

mapping in neo4j

```auto
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

```auto
    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.

---

<div class="post-metadata">

**Author:** ![glilienfield](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/glilienfield/32/27534_2.png) [@glilienfield](https://community.neo4j.com/u/glilienfield)\
**Post date:** [January 29, 2025, 2:52am UTC](https://community.neo4j.com/t/cannot-fetch-child-entity/72476/2 "2025-01-29T02:52:32Z")

</div>

Don’t you need to annotate the ingredient class with @Node. I have this for my related objects.
