Nathan
Nathan

Reputation: 141

Ignoring some entity fields during saving in Objectify 4

I am trying to use Objectify @IgnoreSave annotation along with simple If condition (IfEmpty, IfNull) but it seems that it is not working. Without If condition the actual value is not persisted as expected, however, when I use some If condition, it is always persisted (e.g. if IfNull condition used and null value provided, it is persisted and hence original value in datastore deleted).

...
@IgnoreSave(IfNull.class)
private String email;
...

...
this.objectify.save().entity(userDetails).now();
...

Is there any additional configuration needed? Or has anyone experienced the same?

Upvotes: 0

Views: 1063

Answers (1)

stickfigure
stickfigure

Reputation: 13556

From "hence original value in datastore deleted" it sounds like you misunderstand a fundamental characteristic of the GAE datastore - entities are stored whole. If you @IgnoreSave a field, it will be ignored during save and thus the field will not be present in the datastore. You do not get to update some fields and not others.

Upvotes: 3

Related Questions