LucasM
LucasM

Reputation: 431

Hibernate distinct clause problem

I searched a lot around but cannot find the answer:

I have the following SQL query:

select distinct l.id_book from wa2011.tb_lending as l where l.id_user = 1

It's a very simple query but I cannot manage to write it. How can I write this in HQL?

Thanks a lot! Cheers.

Upvotes: 0

Views: 1224

Answers (1)

FoxyBOA
FoxyBOA

Reputation: 5846

I tested the code with Hibernate 3.3.2 and MS SQL Server and it works fine:

select distinct u.id from User u where u.login='admin'

So I think your HQL code should looks almost the same (just rewrite it from SQL to object model mapped to Hibernate).

Upvotes: 1

Related Questions