• 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

Entity-Home interface-finder exception

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a doubt in Entity Bean Home Interface finder methods.
*Finder methods which returns a remote component i/f throws finder exception and
*Finder methods which returns a collection doesnt throw finder exception instead it will be empty.
*But in HFEJB pgno 275 it is given that even the finder methods with collection as return type throws finder exception.

Please Clear my doubt
 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it goes like this

If the finder method single primary key it should throw javax.ejb.ObjectNotFoundException if the requested entity does not exist and javax.ejb.ObjectNotFoundException is subclass of FinderException


And if it finder method returns a collection of primary key then it should throw FinderException.

I hope it may clear your doubts.

Thanks
 
vinod balaji
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is clearly given that if the finder methods which return collection doesnt find anything it will return empty and not exception. so i think it should not throw finder exception.
But in book it throws finder exception
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
9.5.2 Finder Methods

The throws clause of every finder method on the remote home interface includes the java.rmi.RemoteException and the javax.ejb.FinderException

See also 10.5.6.2 Multi-object finders.
 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see. It is because the Specifications say so.
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The container throws the FinderException to indicate that something went wrong while finding requested entity object invoked by a client.

If an entity is not found, the client gets an ObjectNotFoundException in the case of a single-entity finder and an empty Collection (and no exception) in the case of a multiple-entity finder.

- single-entity finder=====>>>> javax.ejb.ObjectNotFoundException
- multiple-entity finder=====>>>> Empty Collection

FinderException is used to report a failure to find the requested EJB objects. Ans that's why we must need to add it in throws clause of finder method signature.

We must include this exception in the throws clause of all find methods that we declare in the entity bean's home interface and all the ejbFind (in the case of a BMP bean) and ejbSelect methods that we declare in the bean class.

i.e.

findXXX() of Entity Bean's Home interface
ejbFindXXX() of Entity Bean class
ejbSelectXXX() of Entity Bean class


Thanks,
Mahesh

-------
SCJP 1.4, SCWCD 1.4, SCBCD 1.3, (SCEA Part I preparing......)
 
if you think brussel sprouts are yummy, you should try any other food. And this 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