Reputation: 552
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 :
@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 :
@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. I'm at the end of my rope here so I would appreciate any help.
Upvotes: 0
Views: 64
Reputation: 574
objectify
does not index subclasses by default. 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();
Upvotes: 2
Reputation: 24966
I'm wondering if
.filter("userName =", email)
should have been
.filter("email =", email)
Upvotes: 0