Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7942531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:59:57+00:00 2026-06-03T23:59:57+00:00

In development I have an empty datastore. Online I have a datastore with millions

  • 0

In development I have an empty datastore.
Online I have a datastore with millions of entities.

In the development datastore (locally) I put one new entity (generating a new key).
Then I export the entity and put it in the online datastore (with the key generated locally). What is the risk that the key generated locally to have already been assigned to an entity in the online datastore?

Or would it be simpler to avoid collision by creating the keys locally like this:

for (int i = 0; i < data.size(); i++) {
    Key k = KeyFactory.createKey(kind, new Date() + i);
    // continue to creating and inserting entities...
}

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T23:59:59+00:00Added an answer on June 3, 2026 at 11:59 pm

    From https://developers.google.com/appengine/docs/java/datastore/entities:

    Instead of using key name strings or generating numeric IDs
    automatically, advanced applications may sometimes wish to assign
    their own numeric IDs manually to the entities they create. Be aware,
    however, that there is nothing to prevent the Datastore from assigning
    one of your manual numeric IDs to another entity. The only way to
    avoid such conflicts is to have your application obtain a block of IDs
    with the methods DatastoreService.allocateIds() or
    AsyncDatastoreService.allocateIds(). The Datastore’s automatic ID
    generator will keep track of IDs that have been allocated with these
    methods and will avoid reusing them for another entity, so you can
    safely use such IDs without conflict.

    You must either generate all of the numeric keys manually (and in such a way that they will never collide) or use allocateIds(). There is specifically no guarantee that anything you generate manually will not collide with an existing key, unless you use that function. The generated key ids are not like an auto increment field in a relational db which increment by one each time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to Xcode development and have a (hopefully simple) question: I want to
I am new to iphone development.I have created map applications and displayed the cuurent
I am new to iphone development.I have created a UIview controller class and added
I'm new to iPhone development and have run in to a problem. This is
I have a pair of Django models with a foreign key, one of which
I have an empty sqlite3 db. I would like to import a pre-existing one
So I am very new to web development and have a .NET MVC site
I am fairly new in asp.net development, so you can say that I have
I'm new to development. In sql I have written a stored procedure and it
So, I have 2 database instances, one is for development in general, another was

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.