wood burning stoves*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes finder returning collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "finder returning collection" Watch "finder returning collection" New topic
Author

finder returning collection

Chetan Sahasrabudhe
Ranch Hand

Joined: Aug 09, 2004
Posts: 75
Hello,

HF book says that finder method returning single object will throw ObjectNotFoundException, but finders returning Collections will return empty collection for not finding any rows as per the criteria.

Returns empty collection == collection.size() = 0 OR
Returns empty collection == null

Client side validation should be,

OR


Thanks & Regards<br />Chetan
Gemini Moses
Ranch Hand

Joined: Jan 04, 2001
Posts: 245
Returns empty collection == collection.size() = 0
Chengwei Lee
Ranch Hand

Joined: Apr 02, 2004
Posts: 884
The beauty of returning an empty collection as opposed to returning null is that you do not need to incur the overheads of checking if your collection is null/non-null.

You can simply just iterate it as per usual. No checks on whether the size is 0 too (unless your situation warrants it).


SCJP 1.4 * SCWCD 1.4 * SCBCD 1.3 * SCJA 1.0 * TOGAF 8
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: finder returning collection