public Collection findByUserId() throws FinderException, now what will my Collection be if there are no users found? Will it throw a FinderException or will it not? If it is not throwing a FinderException, what value will my collection have? Will it be null or an empty Collection?
Originally posted by Jothi Shankar Kumar Sankararaj: Guys,
I have a method that has the following signature,
public Collection findByUserId() throws FinderException, now what will my Collection be if there are no users found? Will it throw a FinderException or will it not?
IMHO if a function shall trigger an exception it has to build an exception-oject and initiate the handling of the exception. therefore use the key-word "throw"
If it is not throwing a FinderException, what value will my collection have? Will it be null or an empty Collection?
you define it in the find-method by initialisating the return value... ..as I would say...
you define it in the find-method by initialisating the return value... ..as I would say...
I really did not get you...
Steffen Neustadt
Greenhorn
Joined: Sep 30, 2008
Posts: 11
posted
0
Originally posted by Jothi Shankar Kumar Sankararaj:
I really did not get you...
in my opinion you habe a method findxy() with return value of typ collection, right? So you have to return a value of this typ, f.i. public collection findxy(){ //what ever you do, somewhere you have to get a value c // c=new Collection(); c.add(xy);... //c=what you have found; return c;
}
so if nothing found c=empty, or you gave it an other value in your method...
When it is not throwing a FinderException, then why do I have to explicitly say throws FinderException in my component interfaces?
raj
Greenhorn
Joined: Feb 09, 2007
Posts: 8
posted
0
hi, "findbyprimarkey" is a finder method,if this method returns a collection of keys(against a single key) then we will get "finderexception" that's why we should throw finderexceptions for finder methods. for other finder methods, we will return collection.if no records are found to return, then the method will return a empty collection object(not null).
raj
Greenhorn
Joined: Feb 09, 2007
Posts: 8
posted
0
we are returning a collection for finder methods, can we use list or set as a return type for finder methods??
Originally posted by rajeshmanepalli rajeshmanepalli: hi, "findbyprimarkey" is a finder method,if this method returns a collection of keys(against a single key) then we will get "finderexception" that's why we should throw finderexceptions for finder methods. for other finder methods, we will return collection.if no records are found to return, then the method will return a empty collection object(not null).
Your post seems contradictory to what I have tested. Please be clear and format your sentences. I find it hard to follow.