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?