Hibernate delete from onetomany
<p>I have two tables with OneToMany relation</p>

<blockquote>
  <p>class ServiceProvider {</p>
  
  <p>...</p>
  
  <p>@OneToMany(fetch=FetchType.EAGER,mappedBy="serviceProvider",
            cascade={CascadeType.ALL,CascadeType.REMOVE},orphanRemoval = true)
    @OnDelete(action=OnDeleteAction.CASCADE)    private
  List serviceCenters; ...</p>
  
  <p>}</p>
  
  <p>class ServiceCenterDetails {</p>
  
  <p>...   //bi-directional many-to-one association to
  ServiceProviderDomainMap  @ManyToOne
    @JoinColumn(name="SERVICE_PROVIDER_ID")     private ServiceProvider
  serviceProvider;</p>
  
  <p>...</p>
  
  <p>}</p>
</blockquote>

<p>I am trying to delete provide row.  But i am getting below error:</p>

<p>Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (<code>fixoline</code>.<code>service_center_details</code>, CONSTRAINT <code>FK_qvahoxeovx9vmwl6mcu2c0lyw</code> FOREIGN KEY (<code>SERVICE_PROVIDER_ID</code>) REFERENCES <code>service_provider</code> (<code>ID</code>))</p>

<p>below is the way i am trying</p>

<blockquote>
<pre><code>  String hql = "DELETE FROM ServiceProvider WHERE id =  :providerId";
  Query query = sessionFactory.getCurrentSession().createQuery(hql);
          query.setParameter("providerId",providerId);

  int result = query.executeUpdate();
</code></pre>
</blockquote>

<p>could someone pls help resolving it?</p>