If your entities are of the same kind (= same class in JPA), then auto-generated IDs are guaranteed to be unique.
Update: OP clarified that he needs unique IDs across different entity kinds.
You will need to use manually generated IDs - use allocateIds(kind, num)
method where you use a made-up kind
for all. Use num
of 1 to generate only one ID.
long uniqueId = DatastoreService.allocateIds("MyUniqueUserKind", 1).getStart().getId();
All IDs generated this way are always unique as long as you always use the same kind
, in this case "MyUniqueUserKind"
.