• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

FinderException / ObjectNotFoundException

 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what will be the answer of the following question.

If I call findByPrimaryKey(23) on a Home and no object with pk 23 exists,
Which of the following statement is true?

1) I'll get a FinderException.
2) I'll get a ObjectNotFoundException.
3) I can't tell for sure.
4) None of the above.

Now, According to HFEJB, I can't rely on the most specific exception. In that case the answer should be 3. But what's the point of having ObjectNotFoundException if I don't get it surely?
What do u pple think?
regards,
Sajid
 
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the question is about "no object with pk 23 exists" - I think container would get ons instance ready to act as "object with pk 23" as per diagram on page 348 of HFEJB (by pulling one instance out of pool, calling ejbActivate, doing select from DB, then populating EB and then calling ejbLoad).

Only in the scenario when "no entity with pk 23 exists - in the underlying persistent store" the container should throw ObjectNotFoundException. And the specification says that the container *should* throw ObjectNotFoundException, means this more specific exception is recommended, but not mandated.
 
look! it's a bird! it's a plane! It's .... a teeny tiny ad
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic