The five standard application exceptions from the client’s point of view
Two of the five are more specific—DuplicateKeyException and ObjectNotFoundException. If the client gets an ObjectNotFoundException, the client has more information than if he gets a more abstract FinderException. And if the client gets a DuplicateKeyException, he knows a lot more about what went wrong than if he gets a generic CreateException.
CreateException
The client does not know for certain whether the bean was actually created. The Container might have had a problem after the transaction committed.
DuplicateKeyException
If the client catches a DuplicateKeyException, she can be 100% certain that the bean was not created.
FinderException
The client does not know whether a matching entity (or entities, for multiple-entity finders) exists in the database. The Container might throw a FinderException because of something that went wrong before it was able to look in the datbase.
ObjectNotFoundException
If the client catches an ObjectNotFoundException, she can be 100% certain that there was no match for this primary key in the database. Remember, ObjectNotFoundException is for single-entity finders only, so a client will ...
Get Head First EJB now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.