title: Spring Boot JPA One To Many relation - deleting does not work
body: <p>I am dealing with one issue. I have relation one-to-many and in my case it looks like that:</p>
  <pre><code>
  @Data
  @Entity
  public class Event {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private long id;
      private String title;
      ...
      @OneToMany(mappedBy = &quot;event&quot;, cascade = ALL)
      List&lt;TimePeriod&gt; dates;
  </code></pre>
  <p>and TimePeriod entity looks following:</p>
  <pre><code>@Entity
  @Data
  public class TimePeriod {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private long id;
  
      ...
      @ManyToOne
      private Event event;
  }
  </code></pre>
  <p>My JPA repo looks like that:</p>
  <pre><code>@Repository
  public interface TimePeriodRepository extends JpaRepository&lt;TimePeriod, Long&gt;
  {
  }
  </code></pre>
  <p>When i execute following code:</p>
  <pre><code>event.getDates().stream().forEach(d -&gt; {
              timePeriodRepository.deleteById(d.getId());
          });
  </code></pre>
  <p>I dont see that records were removed from database. They are still there. I understand that TimePeriod
  is owning side in my case, so i understand it should work.</p>
  <p>I am operating mainly od event entity, why i put there cascade.ALL option.</p>
  <p>But when i had a cascade.ALL also on TimePeriod then not only related records were removed but also EVENT.</p>
  <p>Another way which i tried i upadated event side like:</p>
  <p>event.setDates(new ArrayList&lt;&gt;());</p>
  <p>but after when i save event i was still able to see those date records in database.</p>
  <p>Can someone let me know what im doing wrongly ?</p>