I have started to migrate from our M/S application to HRD. I wonder if you can recommend me how to convert old string encoded keys to new ones.
I know that string encoded keys holds the application name, although I am not certain if there are other details which I need to take care of. In addition, I could not find any forum-post, which has Java's code example of converting "string encoded keys" which looks quite strange to me (only python forums discuss it).
I will appreciate any help on this matter.
By the way I thought to run the following, although I'm afraid it will not work or cover all aspects:
private static String convertKey(String encodedKey) {
Key key = KeyFactory.stringToKey(encodedKey);
Key newKey = KeyFactory.createKey(key.getKind(), key.getId());
return KeyFactory.keyToString(newKey);
}
Thanks! Uri
Why do you think you need to convert keys? The migration tool will copy over all your data, and in the process it will recreate the keys so that they correctly reference the new app.
The above code will work as long as the Entity is a Parent entity with no other Parents. If you have a Child Entity you will have to migrate the parent key as well.
For Example:
Only then you can use this code
This example applies for only one parent, if you have multiple parents you will have to use this code a few times.
With following recursive function generateKey(Key key) can be covered all cases (cascade parents too) for encoded string key conversions. Other two functions are wrappers for one end key collection conversions. http://www.geotrack24.com