• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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.
 
We cannot change unless we survive, but we will not survive unless we change. Evolving tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic