thanks for you sharing,
quick check. when u return null to our service layer, did u rewrap
with dataNotFoundException ? or returning null all the way back to MVC?
so, at MVC , I assume u will still check if Item=null, show error at
view , etc. , right?
I am just wondering, all the work on catching and throwing and
validating with if & else, scattering at different layers,
hm.. shouldn't be a better way to do it? ....
~thinkboy.
On 2006-12-11 14:17:00 +0800, "Sanjiv Jivan"
<[EMAIL PROTECTED]> said:
Here's how I handle it :
import org.springframework.dao.support.DataAccessUtils;
public Item getItemByName(String name) {
List results = getHibernateTemplate().find("from Item where name=?",
name);
return (Item) DataAccessUtils.uniqueResult(results);
}
The source of DataAccessUtils.uniqueResult is below. As you can see, it
returns null if the collection size is 0 and if the size is greater then 1,
it throws an exception as
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]