title: How to batch delete using bulkUpdate
body: <p>I have a common User / Role setup, with a user_role join table. I'm trying to use Spring's HibernateTemplate to mass delete all locked users like this:</p>
  
  <pre><code>getHibernateTemplate().bulkUpdate("delete from User where locked=?", true);
  </code></pre>
  
  <p>If the user being deleted does not have any roles (no record in the user_role table), then everything goes fine; however if the user does have a role record, I'm getting the following error:</p>
  
  <blockquote>
    <p>integrity constraint violated - child
    record found</p>
  </blockquote>
  
  <p>Roles are defined in User.java like this:</p>
  
  <pre><code>@ManyToMany(fetch = FetchType.EAGER)
  @JoinTable(name = "user_role", joinColumns = { @JoinColumn(name = "user_id") }, inverseJoinColumns = @JoinColumn(name = "role_id"))
  private Set&lt;Role&gt; roles = new HashSet&lt;Role&gt;();
  </code></pre>
  
  <p>So how can I batch delete users even if a user has child records? Thanks!</p>