I've got a problem that I expect is not unusual. I may simply be approaching this the worng way. I'm doing a look up in a table where the primary key may not exists. I'm using session.load( class, Integer ) to find my object.
Person person = (Person)session.load( Person.class, new Integer(personId) );
try{ if(person.getPersonId() > 0); }catch(ObjectNotFoundException e){ // do nothing } // code continues
if you do not know about the primary key, the best practice is to use the methode Session.get(Class clazz, Serializable id), because when a persistent object with this id does not exit, then the method returns null