How to catch integrity constraint deletion error?
<p>There are two database tables role and role_menu. There is foreign key in role_menu referencing role's primary key.</p>

<p>Now I am deleting a row of the master table role which row has a foreign key associated in role_menu. I tried to enclose the delete code inside try catch but the execution does not enter in the catch block :</p>

<pre><code>@Override
@Transactional
public void delete(String role_code) {
    try {
    sessionFactory.getCurrentSession().delete((Role) sessionFactory.getCurrentSession().get(Role.class, role_code));
    } catch (Exception e) {
        System.out.println("error : there is fk !");
    }

}
</code></pre>

<p>In console I got these texts :</p>

<pre><code>WARN : org.hibernate.engine.jdbc.spi.SqlExceptionHelper - SQL Error: 2292, SQLState: 23000
ERROR: org.hibernate.engine.jdbc.spi.SqlExceptionHelper - ORA-02292: integrity constraint (PTA.FK_ROLE_MEN_R_ROLE_ME_ROLE) violated - child record found
</code></pre>

<p>So how to deal with integrity constraint deletion error ?</p>