Distinct using objectify

房东的猫 提交于 2020-04-11 03:10:42

问题


I am working google and engine and objectify, since for the last 3 hours i have been trying to write a distinct query in objectify. Can anyone tell me how to write a distinct query in objectify on a particular column?

Regards, Sreekanth


回答1:


Distinct only works with projection queries, which are not directly supported by Objectify yet. They are on the roadmap. Please star this issue: https://code.google.com/p/objectify-appengine/issues/detail?id=188

In the mean time, you can issue a low-level API query and use objectify's load().fromEntity() to convert the result set to POJOs.




回答2:


Objectify (5.0.5+) now supports projection queries and distinct operation.

ofy().load().type(Entity.class).project("field1").distinct(true);




回答3:


It's important to not that DISTINCT works only with projection queries and I don't believe Objectify currently supports them (it currently returns only whole entities). You can still use the low-level Datastore API to perform a projection query.



来源:https://stackoverflow.com/questions/23154817/distinct-using-objectify

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!