• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

objectnotfoundexception

 
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Page 548 of HF, has the following descrciption of ObjectNotFoundException

The container throws this to the client ONLY during single-entity finder methods, when there's no entity in the database matching the primary key parameter of the finder method.


This statement implies that the only finder method that returns a single-entity is one that takes a primary key parameter. Is this the case, or can a single-entity finder method take paramters that do not include the primary key?
Thanks a mill.
[ January 29, 2004: Message edited by: Keith Rosenfield ]
 
Cowgirl and Author
Posts: 1589
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy -- yeah, *any* single-object finder (including findByPrimaryKey()) can throw an ObjectNotFoundException. Remember, though, that the Container is also free to throw just the superclass FinderException. Whether the Container decides to throw the more specific subclass ObjectNotFoundException is optional, in the spec. But that's a minor point -- the purpose of ObjectNotFoundException (in fact, it's ONLY purpose) is to indicate that a single-object finder did not locate a single object that matches the query.
cheers,
Kathy
 
Keith Rosenfield
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for clearing that up.
 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kathy,
From your answer --

"But that's a minor point -- the purpose of ObjectNotFoundException (in fact, it's ONLY purpose) is to indicate that a single-object finder did not locate a single object that matches the query. "


What about the instance when a reference to a bean (any bean) exists on the client , but the bean instance has been removed and the client tries to invoke a method via the reference - ObjectNotFoundException is thrown isn't it ? This is a valid scenario too - so the "ONLY purpose" might not be technically correct
 
Keith Rosenfield
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Akasmat,
A NoSuchObjectException would be thrown in your scenario NOT a ObjectNotFoundException. The NoSuchObjectException is thrown when an attempt is made to call a method on an EJBObject that no longer exists.
Hope this helps.
 
Goan Balchao
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kathy,
From your answer --

"But that's a minor point -- the purpose of ObjectNotFoundException (in fact, it's ONLY purpose) is to indicate that a single-object finder did not locate a single object that matches the query. "


What about the instance when a reference to a bean (any bean) exists on the client , but the bean instance has been removed and the client tries to invoke a method via the reference - ObjectNotFoundException is thrown isn't it ? This is a valid scenario too - so the "ONLY purpose" might not be technically correct
 
We're all out of roofs. But we still have tiny ads:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic