As far as your example goes you shouldn't have any troubles because
ObjectNotFoundException is a subclass of FinderException.
I have seen some containers perform an ejbLoad() instead of a
findByPrimaryKey() as an optimization. In many cases this is a welcome step
as it reduces the need for a second database call when a FBPK is followed by
a business method call in the same transaction. It's welcome as long as the
ejbLoad() throws an ObjectNotFoundException as expected.
For those of us writing BMP, I typically use ObjectNotFoundException for any
situations where the key was simply not found. I use FinderExceptions for
all other problems (bad sql, etc.). Remember to never use
ObjectNotFoundException with multi-finders. These should always return an
empty collection when no results are found.
jim
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Shahar Solomianik
> Sent: Sunday, March 11, 2001 8:51 AM
> To: [EMAIL PROTECTED]
> Subject: [jBoss-User] Usage of FinderException
>
>
> Hi.
> Can I count on "catch(FinderException ...)" to determine if a CMP entity
> exist or not ?
> for example, if I want to prevent two users registering with same
> email, can
> i do something like this :
>
> try {
> User user = UserHome.findByEmail(email);
> throw new EmailAlreadyExistException();
> }catch (FinderException fe){
> User user = UserHome.create(....);
> }
>
> It worked in Final 2.0, but when using pre2.1, I suspect the
> container threw
> a ObjectNotFoundException instead, and I dont know if FinderException are
> for internal container use or not.
>
> Thanks,
> Shahar.
>
>
>
> --
> --------------------------------------------------------------
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
>
>
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]