-->
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.  [ 1 post ] 
Author Message
 Post subject: Custom EntityNotFoundDelegate
PostPosted: Tue Mar 16, 2010 10:12 am 
Newbie

Joined: Thu Oct 30, 2008 5:52 am
Posts: 5
Location: Germany
Hi all,

I get a org.hibernate.ObjectNotFoundException when I want to delete an object which doesn't exist anymore via hibernate. I just want this exception to be ignored. I could catch the exception and ignore, this would be a solution maybe. But, since there is a hibernate support for ignoring this exception through org.hibernate.cfg.Configuration#entityNotFoundDelegate, I would like to use its advantage and control it using configuration. The question is then, how can I introduce my own/custom implementation of EntityNotFoundDelegate to the org.hibernate.cfg.Configuration? Does anybody have a sample code for me? Just an additional tip, I use Spring Framework as well in my project.

Here is the exception that I get:

Code:
Caused by: org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException: No row with the given identifier exists: [de.mycompany.domain.ResultObject#810b1334-32d3-02b0-e044-769e0ab48e48]; nested exception is org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [de.mycompany.domain.ResultObject#810b1334-32d3-02b0-e044-769e0ab48e48]
   at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:660)
   at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
   at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:424)
   at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
   at org.springframework.orm.hibernate3.HibernateTemplate.delete(HibernateTemplate.java:865)
   at org.springframework.orm.hibernate3.HibernateTemplate.delete(HibernateTemplate.java:859)
   at de.mycompany.utils.dao.impl.PersistentDaoImpl.delete(PersistentDaoImpl.java:50)
   at de.mycompany.utils.service.ServiceImpl.delete(ServiceImpl.java:68)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
   at de.mycompany.utils.service.ServiceInterceptor.invoke(ServiceInterceptor.java:43)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
   at $Proxy3.delete(Unknown Source)
   ... 14 more
Caused by: org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [de.mycompany.domain.ResultObject#810b1334-32d3-02b0-e044-769e0ab48e48]
   at org.hibernate.impl.SessionFactoryImpl$2.handleEntityNotFound(SessionFactoryImpl.java:409)
   at org.hibernate.proxy.AbstractLazyInitializer.checkTargetState(AbstractLazyInitializer.java:108)
   at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:97)
   at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:140)
   at org.hibernate.engine.StatefulPersistenceContext.unproxyAndReassociate(StatefulPersistenceContext.java:594)
   at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:90)
   at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:74)
   at org.hibernate.impl.SessionImpl.fireDelete(SessionImpl.java:793)
   at org.hibernate.impl.SessionImpl.delete(SessionImpl.java:778)
   at org.springframework.orm.hibernate3.HibernateTemplate$26.doInHibernate(HibernateTemplate.java:871)
   at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)
   ... 30 more



And my versions:

Hibernate: 3.3.1
Spring: 2.5.6


Thanks in advance!

Felix

_________________
The identity of a person is what s/he thinks.


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

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.