As stated in this post: Migration to HRD - How to convert string encodings to a new application, all entity keys contain a link to app-id. If you use keys encoded as String, this link will not be updated when copying data to a new application. But you can do it yourself.
Just run the query in the new environment to update each individual key to point to a new application identifier. In this example, I assume that each object implements this interface:
Interface Entity{ public Key getKey(); public void setKey(Key key); }
Now I can use this method:
//... List<Entity> entities = //... your query for (Entity entity : entities){ entity.setKey(generateNewKey(entity.getKey()); } //... //Method written by Nikolay Ivanov in the other post, that recursive generate a new key respecting to parents private Key generateNewKey(Key key) { Key parentKey = key.getParent(); if(parentKey == null){ return KeyFactory.createKey(key.getKind(), key.getId()); }else{ Key newParentKey = generateKey(parentKey); return KeyFactory.createKey(newParentKey, key.getKind(), key.getId()); } }
source share