Good day,
I hv created
Project and
ProjectDtl with one-to-many relationship.
Each call to oProject.getDetails() will return me a full list of the associated details Currently I hv to use a
filter to retrieve the filtered details.
I tried the following code and it still return all the details when I call oProject.getDetails().
Code:
criteria = createCriteria();
criteria.add(Expression.eq(Project.PROP_PROJECTNBR, id));
// Append search criteria for details, sorting order, filter string
criteriaDetail = criteria.createCriteria(ProjectDtl.PROP_DETAILS, ProjectDtl.PROP_DETAILS);
if (stFilterDetails != null && stFilterDetails.length() > 0)
criteriaDetail.add(Expression.ilike(ProjectDtl.PROP_PRRFNBR, stFilterDetails, MatchMode.START));
if ((searchCategoryDetails != null && searchCategoryDetails.length() > 0) &&
(searchStringDetails != null && searchStringDetails.length() > 0))
criteriaDetail.add(Expression.ilike(searchCategoryDetails, searchStringDetails, MatchMode.START));
criteriaDetail.setFirstResult(startRowDetails);
criteriaDetail.setMaxResults(endRowDetails);
list = criteria.list();
I saw in the net that I can use the following code to get the filtered collection.
Code:
list = criteriaDetail.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP).list();
Instead of return a list of Project, the code will return a Hashmap.
Is there any way to apply a criteria object to filter persistent collection and return a list of Project ?
Additional info :
Hibernate version: 3
Name and version of the database you are using: DB2 v8.1