title: JPA Cascade Delete JoinTable Row
body: <p>I have the following class:</p>
  
  <pre><code>public String sport;
  public String date;
  public String time;
  
  @ManyToOne
  public Location location;
  public int min, max;
  // 0 - public, 1 - invite only
  public int scope;
  
  @ManyToOne
  public User creator;
  
  @ElementCollection
  @ManyToMany(fetch = FetchType.EAGER)
  @JoinTable(name = "games_attendees")
  public List&lt;User&gt; attendees;
  
  @ElementCollection
  @ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
  @JoinTable(name = "games_subs")
  public List&lt;User&gt; subs;
  
  @ElementCollection
  @ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
  @JoinTable(name = "games_invitees")
  public List&lt;User&gt; invitees;
  </code></pre>
  
  <p>I do not have any relational mappings in User as I don't think I need this to be bidirectional.</p>
  
  <p>Whenever I try to delete an instance of game, I get this error:</p>
  
  <pre><code>org.hibernate.exception.ConstraintViolationException: could not execute update query
  Caused by: org.postgresql.util.PSQLException: ERROR: update or delete on table "games" violates foreign key constraint "fkc80e3afb4429c99e" on table "games_attendees"
  Detail: Key (id)=(3) is still referenced from table "games_attendees".
  </code></pre>
  
  <p>I have tried all sorts of combinations of LAZY/EAGER and different Cascading types and cannot figure it out. There are several other posts on here, but I don't want the User to be deleted, just the row from the games_attendees table.</p>
  
  <p>*<em>Update:</em>*After troubleshooting for a while, I decided to try executing a native query before my delete statement that just deletes all rows from the games_attendees table (the join table) where the game_ids match. This produces the desired result but it seems to be an anti-JPA way to go about it. Is there a better way?</p>