[英]Google app engine data query returns 0 results
I'm attempting login using google app engine with objectify but since the Google User object doesn't have enough information I created a local Entity that looks like so : 我正在尝试使用带有Objectify的Google App Engine登录,但是由于Google User对象没有足够的信息,因此我创建了一个本地实体,如下所示:
@Cache
@Entity
public abstract class UserData extends RoleUser implements UserDetails {
protected String firstName;
protected String middleName;
protected String lastName;
protected boolean enabled;
protected String phoneNumber;
@Index
protected String email;
@Index
protected String userName;
and I have a subclass for a GoogleUser like so : 而且我有一个GoogleUser的子类,如下所示:
@Subclass
public class GoogleUser extends UserData {
private String googleUserId;
private String authDomain;
Finally the query that I run to see if my custom entity was created for a specific email is like so : 最后,运行查询以查看是否为特定电子邮件创建了自定义实体,如下所示:
public boolean isNewUser(String email){
int count = ofy().load().type(GoogleUser.class).filter("userName =", email).count();
logger.debug("Total accounts for email: |" + email + "| \t Count: " + count);
return count == 0;
}
The problem I'm having is that the query returns 0 results even though I see the entity when I look at datastore through admin on my local appengine server. 我遇到的问题是,即使我在本地appengine服务器上通过admin查看数据存储区时,即使看到该实体,查询也会返回0个结果。 I'm at the end of my rope here so I would appreciate any help. 我在这里尽头了,因此我将不胜感激。
objectify
does not index subclasses by default. 默认情况下, objectify
不会索引子类。 You have to explicitly enable this for each subclass, like so: 您必须为每个子类显式启用此功能,如下所示:
@Subclass(index=true)
public class GoogleUser extends UserData {
private String googleUserId;
private String authDomain;
Note that if you have changed the polymorphic hierarchy of your class you will need to re-save your entity for indexing to work. 请注意,如果您更改了类的多态层次结构,则需要重新保存实体才能使索引正常工作。
Little tip: Having no operator in the filter means == Your query can be written like this 小提示:过滤器中没有运算符意味着==您的查询可以这样写
int count = ofy().load().type(GoogleUser.class).filter("userName", email).list();
I'm wondering if 我想知道
.filter("userName =", email)
should have been 本来应该
.filter("email =", email)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.