I am using CMP 2.0.
I have a finder method. When its not able to find anything database it throws exception. Is this normal behaviour or should it simply return null?
I wonder why it should throw exception, when it can simply return null!
Any ideas or advice is appreciated!
Yes it is normal behavour as defined by the EJB spec to throw an ObjectNotFoundException. I suggest you read the spec on this area.
As for why an exception? well the generally thinking is exceptions force developers to code for case where as checking return a null value can often be overlooked. For CMR finder methods that return collections or Sets, if there is no record then an empty Collection or Set is returned.