-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Help with Expression
PostPosted: Mon Jul 11, 2005 12:30 pm 
Newbie

Joined: Mon May 09, 2005 1:32 am
Posts: 7
Location: Bangalore
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


Top
 Profile  
 
 Post subject: Re: Help with Expression
PostPosted: Mon Jul 11, 2005 1:08 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
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)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.