File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Criteria.list() returns more objects than expected Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Criteria.list() returns more objects than expected" Watch "Criteria.list() returns more objects than expected" New topic
Author

Criteria.list() returns more objects than expected

Jan Hruby
Greenhorn

Joined: Apr 22, 2009
Posts: 4
Hi all,

I have such a problem, that my application returns more identical objects but I want to get only one. This thing happens when I use join formula in my sql statement. When I execute this statement result set has of course more rows beacuse of a join formula. But I want Hibernate to convert it in a single object which owns a list of other objects. Eventually I get such an object but it's copied x times (x stands for resultset row count) in a resulting list.

I'll be thankfull for any suggestion

hbm.xml:


list() method:



other classes:
Jan Hruby
Greenhorn

Joined: Apr 22, 2009
Posts: 4
This solved my problem with more identical root objects.

criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
Randeep Singh Arora
Greenhorn

Joined: May 14, 2010
Posts: 6
I want to try this scenario can you please send me source code for your problem.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Criteria.list() returns more objects than expected
 
Similar Threads
Please suggest on this Mapping
HBM mapping Problem
One to Many relationship Error. Please guide.
Problem with Hibernate Criteria, Query by Example and "nullable=false"
Hibernate Issue