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

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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic