title: how to get all child data and then delete in spring boot
body: <p>I have mapped one to many as follows</p>
  <pre><code>//TourPackage model
  @OneToMany(mappedBy = &quot;packages&quot;, cascade = CascadeType.ALL, fetch = FetchType.LAZY)
  private Set&lt;Itinerary&gt; itineraries;
  
  public Set&lt;Itinerary&gt; getItineraries() {
      return itineraries;
  }
  </code></pre>
  <p>in itinerary model</p>
  <pre><code>@ManyToOne(fetch = FetchType.LAZY)
  @JoinColumn(name=&quot;packages_id&quot;, nullable = false)
  @OnDelete(action = OnDeleteAction.CASCADE)
  private TourPackage packages;
  </code></pre>
  <p>now my update function, update form returns tourPackage and multiple itinerary, so what I want to do is delete all previous itinerary and insert new ones. Where I have written <code>//null returned</code> to my knowledge should return all the itinerary of that package but returns null.</p>
  <pre><code>@PostMapping(&quot;/update-tour-package&quot;)
  public String updateTourPackage(@ModelAttribute(&quot;tourPackage&quot;) TourPackage tourPackage, @RequestParam String[] day, @RequestParam String[] itinerary_title, @RequestParam String[] itinerary_description, @RequestParam String[] itinerary_altitude) {
      
      TourPackage tour = this.tourPackageService.saveTourPackage(tourPackage);
  
      this.itineraryRepo.deleteAll(tour.getItineraries());//null returned for itinerary
  
      for (int i = 0; i &lt; day.length; i++) {
          Itinerary ite = new Itinerary();
          ite.setPackages(tour);
          ite.setDay(day[i]);
          ite.setTitle(itinerary_title[i]);
          ite.setDescription(itinerary_description[i]);
          ite.setAltitude(itinerary_altitude[i]);
          this.itineraryRepo.save(ite);
      }
      return &quot;redirect:/&quot;;
  }
  </code></pre>
  <p>am I doing it right? please point me in right direction. Please comment if I should provide more context to the question.</p>