umesh.b wrote:
Hi ,
Iam facing a problem using createcriteria with expression,
I have somtinh like this.
Criteria criteria = hibernateSession.createCriteria(EmployeeDTO.class);
criteria.add(Expression.eq("deptnum ",DeptNum));
criteria.add(Expression.like("empName",LastName,MatchMode.END));
List values = criteria.list();
Iam getting the size of the list as 6 which is correct.But the DTOs returned is the same i.e i et the same instance of dto 6 times instead of 6 different DTOs.
for (Iterator iter = values.iterator(); iter.hasNext();) {
EmployeeDTO element = (EmployeeDTO) iter.next();
System.out.println("------>EmployeeDTO>>>>"+element);
}
I expect to get six different employee dto instances for the given deptnum and empname which iam passing as argumnets Do i need to make any chages in my hbm file to use this.Kindly help asap.
Thank You
Waiting for reply in early
I'd be more certain if you supplied your mapping files but you probably need to look into criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY)