aspose file tools*
The moose likes Object Relational Mapping and the fly likes Inner Join and unique results Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Inner Join and unique results" Watch "Inner Join and unique results" New topic

Inner Join and unique results

Wojciech Sielski

Joined: Dec 18, 2012
Posts: 7

I'm trying to retrieve data from database using criteriabuilder. It's working great, query is almost perfect... almost. Unfortunately Java don't want me to use group by or distinct as a result of my query. How to make Java retrieve only unique records? My code is here:

Any idea?
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
What error are you getting?


For Criteria groupBy examples.

TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
Wojciech Sielski

Joined: Dec 18, 2012
Posts: 7
There was no error. Just duplicated records. But now I've found bug. I was creating query before I've set distinct parameter to true.
I agree. Here's the link:
subject: Inner Join and unique results
Similar Threads
Searching row in database by a column which is not a primary key
Can anyone tell why is this query not valid?
JPA criteriaBuilder method not found
code review: JPA criteria
How to count the number of rows of a JPA 2 CriteriaQuery in a generic JPA DAO?