Does deferred save in Objectify apply per Java entity or per Google Cloud Datastore entity?

Oliver Hausler

Our app logic has multiple layers. Each time a save is invoked, the entity on the domain layer is mapped to a database entity.

For example:

class Sample(); // the domain entity

@Entity("Sample")
@Cache
class DatabaseSample; // the database entity

Let's assume the domain entity is modified and save is invoked, which will map all properties to a new database entity, which is then saved deferred.

Let's assume the same domain entity is modified again and saved again, which will again map all properties to a new database entity and invoke deferred save.

Will the two separate Google Cloud Datastore entities compete with each other, e.g. the newer save overwrite the older save completely, or will objectify collect modified Key-Value pairs during the request and save a consolidated entity at the end of the request?

stickfigure

I don't quite understand the question, but I'll try to give you some context that might help.

If you defer save of an entity POJO, it just marks it as "save this thing" in the session. When the session closes (end of transaction) anything marked for deferred save (or delete) gets saved.

Only at the very moment of saving to the datastore does the POJO get mapped to a low-level Entity. You can defer save the same object a zillion times with no practical effect. In fact, this is the core use case - you might have a method that sets changes some data and wants a save, and some other method that changes some data and wants a save... by using deferred saves, you avoid making separate real saves to the datastore.

If you're asking about doing something really crazy like changing the @Id after deferring a save... don't. I really have no idea what that will do, but you probably won't like it :-)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Google Datastore - Not Seeing 1 Write per Second per Entity Group Limitation

Google Cloud Objectify - Error saving entity

Output data to Datastore with Entity by Google Cloud Client Library for Java

Put into Google Cloud Datastore fails for interface entity

AttributeError on google cloud datastore entity object

Can the property of an entity be another entity in Google Cloud Datastore?

Google datastore objectify save issue with map

The effect of entity group on transaction in google cloud firestore in datastore mode

Update one property of an entity in google cloud datastore python

Inserting entity to google cloud datastore using REST API

How to always read most recent entity from Google Cloud Datastore

Google Cloud Datastore how to create, update and delete entity with http request

Does supplying an ancestor improve filter queries performance in objectify / google cloud datastore?

Does the entity google datastore could have "empty" property?

Query Entity by Regex Google Datastore

Google App Engine Objectify get grandson of entity

Update entity from appengine .GetAll and save to datastore

Delete specific entity in cloud datastore in nodejs

spacy: set only one entity per type per sentence

Unable to Save Objectify entity with Map<string,Object> in Embedded classes?

Web API OData Security per Entity

hibernate two tables per one entity

Entity Framework: Soft Delete and Table per Type

Consecutive values and associated positions per entity - R

Pandas - Evaluating row wise operation per entity

Entity framework - table per type issue

Table Per Type Fluent Mapping in Entity Framework

Entity Framework Table Per Class Inheritance

Entity Framework with Owin DbContext per request in MVC