-->
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: how to catch ObjectNotFoundExceptio
PostPosted: Thu Mar 11, 2010 3:16 pm 
Beginner
Beginner

Joined: Sun Jan 24, 2010 3:04 am
Posts: 20
Hi!

I have in my code:
Code:
T entity;
      try {
         if (lock)
            entity = (T) getHibernateTemplate().load(persistentClass, id, LockMode.UPGRADE);
         else
            entity = (T) getHibernateTemplate().load(persistentClass, id);
      }catch(ObjectNotFoundException e){
         entity = null;
         LOG.debug("find by id couldn't find " + persistentClass.getName()+ "with id " + id);
      }catch(HibernateObjectRetrievalFailureException e){
         entity = null;
         LOG.debug("find by id couldn't find " + persistentClass.getName()+ "with id " + id);
      }

but i still see in the log the exepction!
org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.sintecmedia.model.Program#1001003]
at org.hibernate.impl.SessionFactoryImpl$2.handleEntityNotFound(SessionFactoryImpl.java:409)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:171)
at org.hibernate.event.def.DefaultLoadEventListener.lockAndLoad(DefaultLoadEventListener.java:341)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:129)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:905)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:886)

Does handleEntityNotFound print out to the log the excpetion? I would like to handle it myself.. and not write a long trace..
how can i catch it myself?


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.