-
1. Re: single-entity vs. collection find method
dsundstrom Dec 9, 2002 5:49 PM (in response to jlisle)FinderException is a very generic exception and can mean anything from the database crashed to the object was not found. If you are only interested in ObjectNotFoundException, only catch that one. BTW, I think in the proposed EJB 2.1 spec the changed this to not throw an exception and instead return null.
-
2. Re: single-entity vs. collection find method
jboynes Dec 9, 2002 7:01 PM (in response to jlisle)EJB2.1 still throws ObjectNotFoundException is nothing was found. The scenarios are:
* Zero objects matched: throw ObjectNotFoundException
* Exactly one object matched and the value was not null: return the remote/local reference
* Exactly one object matched and the value was null: return null
* More than one object matched: throw FinderException
* Something else went horribly wrong: throw FinderException (or possibly RemoteException)
The null case is allowing the finder to differentiate between finding no data and finding data but having an unknown value. This could happen in an optional realtionship e.g. a Node bean with a finder
Node findParent(Node child)
where the child exists but does not have a parent.
This could happen with EJB2.0 (or 1.1) but the 2.1 spec is now specifically describing it. -
3. Re: single-entity vs. collection find method
dsundstrom Dec 10, 2002 4:24 PM (in response to jlisle)Thanks for the summary. I haven't read the spec to closely myself.