• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Home business methods and finder exception

 
Keith Rosenfield
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On page 398 of HF the two home business methods are throwing FinderExceptions. Is this a requirement of home business methods? I couldn't find this requirement in the book or the spec.
Thanks.
 
Kathy Sierra
Cowgirl and Author
Rancher
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy -- your home business methods are not required to define a FinderException.
However... if your home business method uses a select method, then that select method can *definitely* throw a FinderException, so you MUST declare a FinderException on your ejbSelect methods.
Always.
But you do *not* have to declare a FinderException on all of your home business methods. Remember, some home business methods may not be doing any kind of query, so a FinderException would not be appropriate.
Now, if your home business method invokes a select method, then since the select method MUST declare a FinderException, that means your bean's home business method MUST either handle or declare the FinderException. You will almost always want to declare it, not catch it. (Or catch it but still declare it for times when you still can't be successful from the catch block). But there is no requirement that your home business method MUST declare the FinderException. In other words, once you get into the bean class, the ONLY rule is that the ejbSelect method MUST declare a FinderException. How you handle that from your home business method is up to you, but virtually always... you will declare a FinderException on your home business method (to reflect the FinderException which can be generated by the ejbSelect method that the Container implements), which means that your home interface must ALWAYS declare that FinderException on the home business method.
This is a good question!
Kathy
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic