使用setDistinct()的Ebean查询不起作用 [英] Ebean query using setDistinct() does not work

查看:176
本文介绍了使用setDistinct()的Ebean查询不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在剧中使用一个ebean查询!框架以基于不同的列查找记录列表.看来这是一个非常简单的查询,但问题在于ebean方法setDistinct(true)并未将查询设置为与众不同.

I'm using an ebean query in the play! framework to find a list of records based on a distinct column. It seems like a pretty simple query but the problem is the ebean method setDistinct(true) isn't actually setting the query to distinct.

我的查询是:

List<Song> allSongs = Song.find.select("artistName").setDistinct(true).findList();

在我的结果中,我得到了重复的歌手姓名.

In my results I get duplicate artist names.

从我所见,我相信这是正确的语法,但是我可能是错的.我将不胜感激.谢谢.

From what I've seen I believe this is the correct syntax but I could be wrong. I'd appreciate any help. Thank you.

推荐答案

我只是突然遇到了同样的问题,无法解决.正如hfs所说,它已在更高版本中修复,但是如果您卡住了一段时间,则可以使用

I just faced the same issue out of the blue and can not figure it out. As hfs said its been fixed in a later version but if you are stuck for a while you can use

findSet()

因此在您的示例中使用

List<Song> allSongs = Song.find.select("artistName").setDistinct(true).findSet();

这篇关于使用setDistinct()的Ebean查询不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆