Reputation: 542
I am new to app engine development. I am using Java for development. Whenever a new entity is added it shows an "id=5076324926357504", which wasn't part of entity. I have few queries about this:
Upvotes: 0
Views: 72
Reputation: 560
You can indirectly use it as a primary key by making one of your attributes in the entity, as ID. For example ,In the below code slno which is also an attribute of kind "Registration" is used as an entity id.
Key dbkey=KeyFactory.createKey("Registration", slno);
Entity E1= new Entity("Registration",dbkey);
E1.setProperty("Slno",slno);
E1.setProperty("Name",name);
Now,whenever a new entity is added its slno attribute acts a unique identifier i.e. only one entity containing unique slno can be added. If same slno is given twice , instead of creating a new entity ,the previous entity will be overwritten.
Upvotes: 2
Reputation: 564
Take a look at: https://developers.google.com/appengine/docs/java/datastore/entities#Java_Kinds_and_identifiers
Upvotes: 0