Hello,
I got a problem while trying to delete an instance of type 'Periode' : the first time i try, i got a DataAccessException because there are instances of 'InfosVentes' which are linked to instances of 'Articles' which belongs to the instance of 'Periode' i want to delete > normal and expected behaviour : i catch it and display a usr-friendly warning message.
But when i try again to delete the periode (or any other) again, i got a tomcat error message.
Does anyone can help me and tell me what's wrong in my code and why 2nd try doesn't behave as first? (code and mapping below)
Thanks in advance
P.S. : I also posted this topic on Spring Forum and they said I should rather post it on Hibernate Forum (what i did...) soplease don't tell me it's a spring subject...
Hibernate version: 2.1
Mapping documents:
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>
<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="sousSecteur" column="co_sous_secteur" class="SousSecteur" cascade="none" outer-join="true" />
<many-to-one name="periode" column="id_periode" class="Periode" cascade="none" outer-join="true" />
</class>
<class name="InfoVentes" table="info_ventes">
<id name="id" column="id_info_ventes" type="integer" unsaved-value="null">
<generator class="sequence">
<param name="sequence">seq_info_ventes</param>
</generator>
</id>
<property name="qteLivree" column="nb_qte_livree" type="integer" />
<property name="qteVendue" column="nb_qte_vendue" type="integer" />
<property name="qtePerdue" column="nb_qte_perdue" type="integer" />
<property name="qteRecomm" column="nb_qte_preconisee" type="integer" />
<property name="site" column="id_site" type="integer" />
<many-to-one name="article" column="id_article" class="Article" cascade="none" outer-join="true" />
</class>
CodeCode:
public class PeriodeDAOImpl implements PeriodeDAO {
public void delete(final Object obj) throws DataAccessException {
hibernateTemplate.execute(new HibernateCallback() {
public Object doInHibernate(Session session) throws HibernateException {
session.delete(obj);
session.flush();
return null;
}
});
}
}
Full stack trace of any exception that occurs:Code:
Code:
java.lang.NullPointerException
oracle.jdbc.driver.OraclePreparedStatement.processCompletedBindRow(OraclePreparedStatement.java:1581)
oracle.jdbc.driver.OraclePreparedStatement.addBatch(OraclePreparedStatement.java:8540)
org.apache.commons.dbcp.DelegatingPreparedStatement.addBatch(DelegatingPreparedStatement.java:257)
org.apache.commons.dbcp.DelegatingPreparedStatement.addBatch(DelegatingPreparedStatement.java:257)
net.sf.hibernate.impl.BatchingBatcher.addToBatch(BatchingBatcher.java:30)
net.sf.hibernate.persister.EntityPersister.delete(EntityPersister.java:583)
net.sf.hibernate.impl.ScheduledDeletion.execute(ScheduledDeletion.java:29)
net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2438)
net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2396)
net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2260)
com.match.ventestrad.dao.hibernate.ObjectDAOImpl$2.doInHibernate(ObjectDAOImpl.java:78)
org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:150)
com.match.ventestrad.dao.hibernate.ObjectDAOImpl.delete(ObjectDAOImpl.java:75)
com.match.ventestrad.dao.hibernate.PeriodeDAOImpl.delete(PeriodeDAOImpl.java:91)
com.match.ventestrad.service.PeriodeService$7.doInTransaction(PeriodeService.java:136)
org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:114)
com.match.ventestrad.service.PeriodeService.deletePeriode(PeriodeService.java:133)
com.match.ventestrad.web.actions.GererPeriodesAction.perform(GererPeriodesAction.java:71)
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