Hibernate version: 2.1
Full stack trace of any exception that occurs:
org.springframework.dao.DataIntegrityViolationException: (HibernateTemplate): data integrity violated by SQL 'null'; nested exception is java.sql.BatchUpdateException: ORA-02292: integrity constraint (VENTES_TRAD.FK_INFO_VEN_CONCERNE_ARTICLE) violated - child record found
org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.translate(SQLStateSQLExceptionTranslator.java:82)
org.springframework.orm.hibernate.HibernateTransactionManager.convertJdbcAccessException(HibernateTransactionManager.java:516)
org.springframework.orm.hibernate.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:394)
org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:314)
org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:126)
com.match.ventestrad.service.PeriodeService.deletePeriode(PeriodeService.java:133)
com.match.ventestrad.web.actions.GererPeriodesAction.perform(GererPeriodesAction.java:66)
org.apache.struts.action.ActionServlet.processActionPerform(ActionServlet.java:1787)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1586)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:492)
javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
Name and version of the database you are using: Oracle 8.1.7
MAPPING Of objects :
Code:
<class name="Periode" table="periode">
<id name="id" column="id_periode" type="integer" unsaved-value="null">
<generator class="sequence">
<param name="sequence">seq_periode</param>
</generator>
</id>
<property name="libelle" column="lc_libelle" type="string" />
<property name="dateDebut" column="da_date_debut" type="date" />
<property name="dateFin" column="da_date_fin" type="date" />
<property name="visibleMags" column="fl_visible_mag" type="boolean" />
<bag name="articles" table="article" lazy="true" inverse="true" cascade="all-delete-orphan" order-by="co_sous_secteur, co_code">
<key column="id_periode" />
<one-to-many class="Article" />
</bag>
</class>
<!-- Mapping de la classe com.match.ventestrad.domain.Article -->
<class name="Article" table="article">
<id name="id" column="id_article" type="integer" unsaved-value="null">
<generator class="sequence">
<param name="sequence">seq_article</param>
</generator>
</id>
<property name="code" column="co_code" type="string" />
<property name="libelle" column="ll_libelle" type="string" />
<many-to-one name="periode" column="id_periode" class="Periode" cascade="none" outer-join="true" />
</class>
My problem : i'm trying to delete an object 'Periode' which contains a list of objects 'Article' with this code :Code:
public void delete(final Object obj) throws DataAccessException {
hibernateTemplate.execute(new HibernateCallback() {
public Object doInHibernate(Session session) throws HibernateException {
session.delete(obj);
return null;
}
});
}
and i got an exception because of an integrity violation (that's normal). But what is not normal is that i can't manage to catch the exception so as to write a 'decent' message instead of having an horrible stacktrace on my html page...
Anyone has an idea why the Exception is not caught?
(DataIntegrityViolationException is a subclass od DataAccessException so I thought it would be caught...)
Thx in advance