-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Error when I try delete object with association
PostPosted: Fri Nov 04, 2005 9:18 am 
Newbie

Joined: Tue Nov 01, 2005 6:38 am
Posts: 4
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.0

Mapping documents:

<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping default-lazy="false" >
<class
name="gov.anp.educa.vo.AtividadeEnsinoVO"
table="ATIVIDADEENSINO"
dynamic-update="false"
dynamic-insert="false"
>

<id
name="id"
column="idAtividadeEnsino"
type="java.lang.Long"
unsaved-value="0"
>
<generator class="native">
<param name="sequence">idAtividadeEnsino</param>
</generator>
</id>

<property
name="descricao"
type="java.lang.String"
update="true"
insert="true"
column="descricao"
/>

<property
name="nome"
type="java.lang.String"
update="true"
insert="true"
column="nome"
/>

<property
name="sigla"
type="java.lang.String"
update="true"
insert="true"
column="sigla"
/>

<many-to-one
name="tipoAtividadeEnsino"
class="gov.anp.educa.vo.TipoAtividadeEnsinoVO"
cascade="none"
outer-join="false"
update="true"
insert="true"
column="idTipoAtividadeEnsino"
not-null="false" />

<many-to-one
name="atividadeEnsinoPai"
class="gov.anp.educa.vo.AtividadeEnsinoVO"
cascade="all"
outer-join="true"
update="true"
insert="true"
column="idAtividadeEnsinoPai"
not-null="false" />

<set
name="atividadesEnsino"
table="ATIVIDADEENSINO"
lazy="false"
inverse="true"
cascade="all"
sort="unsorted"
>

<key
column="idAtividadeEnsinoPai"
>
</key>

<one-to-many
class="gov.anp.educa.vo.AtividadeEnsinoVO"
/>
</set>

<set
name="gradeCurricular"
table="GRADECURRICULAR"
lazy="false"
inverse="true"
cascade="all"
sort="unsorted"
>

<key
column="idAtividadeEnsino"
>
</key>

<one-to-many
class="gov.anp.educa.vo.GradeCurricularVO"
/>
</set>

<set
name="RHAtividadeEnsino"
table="RHATIVIDADEENSINO"
lazy="false"
inverse="true"
cascade="all"
sort="unsorted"
>

<key
column="idAtividadeEnsino"
>
</key>

<one-to-many
class="gov.anp.educa.vo.RHAtividadeEnsinoVO"
/>
</set>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-AtividadeEnsinoVO.xml
containing the additional properties and place it in your merge dir.
-->

</class>

<!--
To add non XDoclet query mappings, create a file named
hibernate-queries-AtividadeEnsinoVO.xml
containing the additional properties and place it in your merge dir.
-->

</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:
[Educa] ERROR [main] (AppObjetoNegocioBO.java:450) - Ocorreu a exceção ao excluir: deleted object would be re-saved by cascade (remove deleted object from associations): [gov.anp.educa.vo.AtividadeEnsinoVO#25]
gov.anp.framework.comuns.AppException: deleted object would be re-saved by cascade (remove deleted object from associations): [gov.anp.educa.vo.AtividadeEnsinoVO#25]
at gov.anp.framework.modelo.AppObjetoNegocioBO.excluir(AppObjetoNegocioBO.java:451)
at gov.anp.educa.modelo.AtividadeEnsinoBO.main(AtividadeEnsinoBO.java:91)
org.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations): [gov.anp.educa.vo.AtividadeEnsinoVO#25]
at org.hibernate.impl.SessionImpl.forceFlush(SessionImpl.java:742)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:166)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:96)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:468)
at org.hibernate.engine.Cascades$5.cascade(Cascades.java:154)
at org.hibernate.engine.Cascades.cascadeAssociation(Cascades.java:771)
at org.hibernate.engine.Cascades.cascade(Cascades.java:720)
at org.hibernate.engine.Cascades.cascadeCollection(Cascades.java:895)
at org.hibernate.engine.Cascades.cascadeAssociation(Cascades.java:792)
at org.hibernate.engine.Cascades.cascade(Cascades.java:720)
at org.hibernate.engine.Cascades.cascade(Cascades.java:847)
at org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:121)
at org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:112)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:59)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
at gov.anp.framework.modelo.Persistence.commitTransaction(Persistence.java:183)
at gov.anp.framework.modelo.Persistence.confirmaGravacao(Persistence.java:365)
at gov.anp.framework.modelo.AppObjetoNegocioBO.excluir(AppObjetoNegocioBO.java:444)
at gov.anp.educa.modelo.AtividadeEnsinoBO.main(AtividadeEnsinoBO.java:91)


Name and version of the database you are using:SQLServer

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:
Hi guys,
when I try delete an object that have an association, the hibernate show me this error: deleted object would be re-saved by cascade (remove deleted object from associations):
I deleted all the objects associated to the principal object, but the hibenate still show me the error.
Do AnyBody know what happened?

Thanks,
Gustavo Costa


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 04, 2005 11:25 am 
Beginner
Beginner

Joined: Thu Jan 22, 2004 8:22 pm
Posts: 48
In my experience this exception means exactly what it says. You have deleted a instance of the class named in the exception. This same instances is now being saved. This most commonly happens when you delete a instance by leave a reference from another persistent instance causing the deleted instance to be resaved by cascade.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.