nnnn
nnnn

Reputation: 63

what difference, when using objectify?

Ask from here what difference between:

Profile profile = ofy().load().type(Profile.class).id(userId).now();

and

Profile profile = ofy().load().key(Key.create(Profile.class, userId)).now();

why we must create key for userId using Key.create(Profile.class, userId)? Thanks.

Upvotes: 2

Views: 77

Answers (1)

konqi
konqi

Reputation: 5227

The only difference is that the first example does a key query by defining the key implicitly. The second defines the key explicitly.

Both will result in the very same key query.

You don't have to create the key for userId explicitly. But that way it's more obvious what you're doing.

Upvotes: 2

Related Questions