I thought that the list() function used on a query should return null if no records was found. We have som cases where it does not return null, but the list.size() returns 0. This means that we have to check both for null and size=0 after queries. Is this correct?
String myQuery = "from myTable mtable where colA = :queryParam";
List myList = (List) session.createQuery(myQuery)
.setParameter("queryParam", "hibernate"
.list();
if (myList == null || myList.size() == 0) {
Log.debug(lctx, "Exit - no result", DebugLevel.FINE);
return; // RETURN ERROR
}
|