Question

Is it possible to use PostgreSQL-like DISTINCT ON in EJB-QL query?

What i need to do is to fetch from db records that are distinct on 3 of 10 columns.

Was it helpful?

Solution

Why don't you post your entities?

Imagine there is a Customer who has multiple Reservations. This query will return duplicates if the Customer has more than one Reservation:

SELECT c FROM Reservation r, IN(r.customer) c

Using the DISTINCT keyword ensures that each customer is represented once in the results:

SELECT DISTINCT c FROM Reservation r, IN(r.customer) c

I hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top