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: net.sf.hibernate.ObjectDeletedException:
PostPosted: Thu Dec 23, 2004 3:04 am 
Newbie

Joined: Tue Aug 24, 2004 4:25 am
Posts: 14
Hibernate version: 2.1.6

Mapping documents:
<class name="User" table="T_FIN_USER">

<id name="userID" column="USER_ID" type="string" unsaved-value="null">
<generator class="assigned"/>
</id>

<set name="buUserRel" inverse="true" cascade="all-delete-orphan">
<key column="USER_ID"/>
<one-to-many class="BuUserRel"/>
</set>

<property name="password" column="PASSWORD" type="string"/>
<property name="name" column="NAME" type="string"/>
<property name="badgeNo" column="BADGE_NO" type="string"/>
<property name="financeInd" column="FINANCE_IND" type="string"/>

<!-- Apply to all object derrived from BaseBO -->
<property name="createdBy" column="CREATED_BY" type="string"/>
<property name="createdDt" column="CREATED_DT" type="timestamp"/>
<property name="lastModifiedBy" column="LAST_MODIFIED_BY" type="string"/>
<property name="lastModifiedDt" column="LAST_MODIFIED_DT" type="timestamp"/>

</class>

<class name="BuUserRel" table="T_FIN_BU_USER_REL">

<id name="id" column="ID" type="long" unsaved-value="null">
<generator class="increment"/>
</id>

<many-to-one name="bu" column="BU_NO" class="BU" not-null="true"/>

<many-to-one name="user" column="USER_ID" class="User" not-null="true"/>

<!-- Apply to all object derrived from BaseBO -->
<property name="createdBy" column="CREATED_BY" type="string"/>
<property name="createdDt" column="CREATED_DT" type="timestamp"/>
<property name="lastModifiedBy" column="LAST_MODIFIED_BY" type="string"/>
<property name="lastModifiedDt" column="LAST_MODIFIED_DT" type="timestamp"/>

</class>


Code between sessionFactory.openSession() and session.close():
session = getSession();
Transaction tx = session.beginTransaction();
User oldUser = (User)session.get(User.class, user.getUserID());
loop through created objects
oldUser.getBuUserRel().add(buUserRel);
endloop
loop through removed objects
oldUser.getBuUserRel().remove(oldBuUserRel);
endloop

If I don't have removed objects, then every thing is ok, the created objects are created in database. But when I reach the remove code, I have this:
Full stack trace of any exception that occurs:
net.sf.hibernate.HibernateException: net.sf.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations): 9, of class: com.psca.M28000.bo.BuUserRel
at com.psca.M28000.dao.M28000_DAO.updateUser(M28000_DAO.java:424)
at com.psca.M28000.action.EditUserOnSubmitAction.execute(EditUserOnSubmitAction.java:67)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:417)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:768)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
at oracle.security.jazn.oc4j.JAZNFilter.doFilter(Unknown Source)
at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:604)
at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317)
at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)
at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
at java.lang.Thread.run(Thread.java:534)


Name and version of the database you are using: Oracle 9i

I don't know what is going on?

Any help is appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 23, 2004 1:55 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You're resaving and object by cascade, which have been deleted in the session. Be sure to update you association from a Java POV (esp bidirectional ones)

_________________
Emmanuel


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.