This week's giveaway is in the OCPJP forum.
We're giving away four copies of Practice Tests for OCP Java 17 Certification Exam (1Z0-829) and have Paul Anilprem on-line!
See this thread for details.
Win a copy of Practice Tests for OCP Java 17 Certification Exam (1Z0-829) this week in the OCPJP forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

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
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic