I don't think that a group by is designed to remove duplicates, you probably want to select distinct. However, in Hibernate if you are using eager fetching you might still end up with duplicates so you may have to remove them yourself.
This topic might provide some clues: http://www.javalobby.org/java/forums/t68781.html Vincent On Fri, Sep 12, 2008 at 6:42 AM, Joey122 <[EMAIL PROTECTED]> wrote: > I ve been blown away by how neat Appfuse is and its been a great > kickstart. > > I m trying to ensure that duplicates are removed from the data returned by > hibernate by forcing a group by - So far I ve tried to use the Projection > group property on the criteria as follows: > > criteria.setProjection(Projections.projectionList().add( > Projections.groupProperty("landlord_details").as( "landlord_details")).add( > Projections.groupProperty("landlord_agent_details").as( > "landlord_agent_details"))); > > However this no longer returns all the data I need and only returns the > columns which I have grouped by which is wrong :( > > Can anyone give a pointer on how to force a group by on certain columns > whilst still keeping all the other columns that I need? > ------------------------------ > View this message in context: Forcing A Group By In > Hibernate<http://www.nabble.com/Forcing-A-Group-By-In-Hibernate-tp19453450s2369p19453450.html> > Sent from the AppFuse - User mailing list > archive<http://www.nabble.com/AppFuse---User-f2370.html>at Nabble.com. >
