开发者

Hibernate distinct clause problem

I search开发者_如何学编程ed 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.


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜