对象化从实体查询属性 [英] Objectify Query a attribute from an entity

查看:112
本文介绍了对象化从实体查询属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以使用Objectify查询某个实体的特定属性, 可以说我有一个具有属性的类实体{id,name ,邮件} ,如何只从实体过滤邮件属性?先前我正在提取整个实体

  Objectify ofy = ObjectifyService.begin(); 
查询< entity> Q = ofy.query(entity.class);

然后检索q.getmail();



我正在寻找仅在查询q中过滤来自实体 * 的 * 邮件属性?请让我知道如何做到这一点。 解决方案

用查询加载整个实体作为bean。有没有真正的SQL的同义词从实体选择邮件其中id =?客观化。你可以做的是在你使用LoadGroups(https://code.google.com/p/objectify-appengine/wiki/BasicOperations###########################################################################################) Load_Groups),但我不认为这就是你要求的。



也就是说,获取1个字段并获取整个对象在appengine中花费的时间基本相同。

Is there a possible way to query a particular attribute from an entity using Objectify,

Lets say i have an Class entity with attributes {id,name,mail},how to filter only the mail attribute from the entity ? previously I was fetching the entire entity

Objectify ofy=ObjectifyService.begin();
Query<entity> q=ofy.query(entity.class);

and then retrieving the value q.getmail();

I am looking for filtering only *mail attribute from entity * in the query q ? please let me know how to do it.

解决方案

That's not how objectify works. You load the entire entity as a bean with a query. There's not really a synonym for SQL "select mail from entity where id=?" in objectify. What you can do is control which associated entities in the graphy are loaded from the datastore when you do a fetch (in objectify 4) using LoadGroups (https://code.google.com/p/objectify-appengine/wiki/BasicOperations#Load_Groups) but I don't think that's what you are asking.

That said, fetching 1 field and fetching an entire object take basically the same amount of time in appengine.

这篇关于对象化从实体查询属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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