it has both pros and cons. now if you are not sure if the get will work, you need to build a try catch block.
with null you could just do an if null check.

but when i think about it it should be very rare that someone tries to do a get with a wrong primary key.
(in my case it was from a testcase ;) )

tibi

hiugong.gwok wrote:
Well, IMHO it's better than a clueless NPE came out of nowhere, not ideal
though.


tibi-3 wrote:
here is the get method. it will return a runtime exception when nothing is found.
i wonder why not return null?

thanks,

tibi

    /**
     * Generic method to get an object based on class and identifier. An
     * ObjectRetrievalFailureException Runtime Exception is thrown if
     * nothing is found.
     *
     * @param id the identifier (primary key) of the object to get
     * @return a populated object
     * @see org.springframework.orm.ObjectRetrievalFailureException
     */
    public T get(PK id);

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to