Search code examples
javagoogle-cloud-datastoredatastore

Google Datastore convert POCO to Entity


I am using Google Datastore as DB. This is the code I have been using.

DatastoreService datastore = getDataStoreService();
Key rootKey = getRootKey(identity, entityTypeEnum);

The problem is for the entire solution to put any entity I have to use

Entity entity = getOrCreateEntity(EntityTypeEnum.AdminData);
entity.setProperty(Constants.ID, auditEntry.getId());
entity.setProperty(Constants.APPNAME, auditEntry.getId());
getDataStoreService().put(entity);

What I want is there any way we can use generics here? or any entity framework kind of framework which we can use for entire application.

So, convert POCO class to Entity while storing and retrieving?

I could not find any help from GCP documents.


Solution

  • It looks like you are looking for an ODM like Objectify or Spring Data for Datastore.