-->
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.  [ 3 posts ] 
Author Message
 Post subject: ObjectedDeletedException for cascade all-delete-orphan
PostPosted: Fri Nov 18, 2005 7:28 pm 
Newbie

Joined: Sat Oct 29, 2005 1:23 pm
Posts: 15
Location: England
Hibernate version: JBoss 4.0.2

Name and version of the database you are using:Microsoft SQLServer

I am trying to delete a class that has a Set of mappings to its super class:
Group extends Principal.
Principal has a set of Groups (Set<Group> groupMappings)
Group has a set of Principals (Set<Principal> principalMappings)

This allows me to get every member of a group and find out from a group member what groups he is a member of.

When deleting a Group that has a set of child groups I am getting an ObjectDeletedException.

The class PrincipalGroup that maps a Principal to a Group has the group side of the mapping set to lazy=true. All other mappings are lazy=false.

I have tried changing these settings, but this has made no difference.

My code for deleting the Group is as follows:
Code:
public void deleteGroup(String realm, String group) throws SecurityDomainException
   {
      //Open session
      Session session = sessionFactory.openSession();
      
      //Get realm and group
      Realm r = DomainFacade.getInstance(session).getRealm(realm);
      Group g = DomainFacade.getInstance(session).getGroup(r, group);
      
      //Delete it.
      DomainFacade.getInstance(session).delete(g);
      
    //Close session
    session.close();
   }


DomainFacade is a singleton and the getInstance sets the session.

The code for delete in DomainFacade is as follows:

Code:
   public void delete(Object o)
   {
      //Begin transaction
      Transaction transaction = session.beginTransaction();
   
    //Delete
    session.delete(o);
   
    //Commit transaction
    transaction.commit();      
   }


Does anyone have any ideas, or has anyone else experienced this same problem?

Any help will be much apprecieated.

_________________
Jamie Cash
eCommerce Consultancy Limited
The eSecurity Experts


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 19, 2005 6:53 am 
Newbie

Joined: Sat Oct 29, 2005 1:23 pm
Posts: 15
Location: England
I have tried this with a simple case, which still fails:
A single group 'clients' contains a single user principal 'noris'

Delete group 'clients' and the delete fails with the same exception.

Stack trace is included below:
Code:
Caused by: org.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations): [uk.co.eccgroup.security.domain.authorisation.PrincipalGroup#50]
   at org.hibernate.impl.SessionImpl.forceFlush(SessionImpl.java:728)
   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:454)
   at org.hibernate.engine.Cascades$5.cascade(Cascades.java:153)
   at org.hibernate.engine.Cascades.cascade(Cascades.java:721)
   at org.hibernate.engine.Cascades.cascadeCollection(Cascades.java:860)
   at org.hibernate.engine.Cascades.cascade(Cascades.java:739)
   at org.hibernate.engine.Cascades.cascade(Cascades.java:817)
   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:716)
   at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:310)
   at org.hibernate.transaction.JTATransaction.commit(JTATransaction.java:119)
   at uk.co.eccgroup.security.domain.DomainFacade.delete(DomainFacade.java:449)
   at uk.co.eccgroup.security.session.SecurityAdminSessionBeanImpl.deleteGroup(SecurityAdminSessionBeanImpl.java:622)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
   at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:214)
   at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
   at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:130)
   at org.jboss.webservice.server.ServiceEndpointInterceptor.invoke(ServiceEndpointInterceptor.java:51)
   at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
   at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:105)
   at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:335)
   at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:166)
   at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:139)
   at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
   ... 52 more


My mapping files are autogenerated by XDoclet, but I have included a link to them below:


http://www.ecommerce-consultancy.co.uk/files/hibmap

Regards

_________________
Jamie Cash
eCommerce Consultancy Limited
The eSecurity Experts


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 19, 2005 7:33 am 
Newbie

Joined: Sat Oct 29, 2005 1:23 pm
Posts: 15
Location: England
I have fixed this issue by setting lazy=true for all lazy settings. This does create an issue in that the members of a group cannot be determined after the hibernate session has closed, but will have to do for now.

Regards

_________________
Jamie Cash
eCommerce Consultancy Limited
The eSecurity Experts


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.