@Ian Thanks a lot for detailing the solution so clearly. There is one more thing I forgot to add.
The field in question is @PrimaryKey :( The first approach won't work right? I guess running a task to copy the fields is the only option left (I have a little over 1.3 million entities!!) And, once I copy the fields, will I be able to change the @PrimaryKey , to the new field? Is that even possible? -Nischal On Apr 17, 12:27 am, Ian Marshall <[email protected]> wrote: > OK, let us assume that your original persistent field, and its getter > and setter methods, are something like below (using JDO): > > @Persistent > private Integer iValue; > > public Integer getValue() > { > return iValue; > } > > public void setValue(Integer value) > { > iValue = value; > } > > Assuming that you want to preserve your old Integer values, one thing > you could do, for a gradual change-over, is create a new Long > persistence field to something like the code snippet below, where the > new Long field has an instant effect on your code, and an eventual > effect in the datastore. > > @Persistent > private Integer iValue; > > @Persistent > private Long loNewValue; > > public Long getValue() > { > Long loResult = loNewValue; > > if ((loResult == null) && (iValue != null)) > loResult = new Long(iValue.longValue()); > > return loResult; > } > > public void setValue(Long value) > { > loNewValue = value; > iValue = null; > } > > This way, your code thinks that you now have a single Long field, and > it uses old Integer values until they get overwritten with a new one. > > An alternative way is to write some code to iterate through all your > instances, setting the new field with the value from the old, but if > you have lots of instances then you may have to break this operation > up into smaller chunks. > > If you don't need to preserve your old data, then forget what I have > said above since your task becomes easier. > > Have fun! > > -- > You received this message because you are subscribed to the Google Groups > "Google App Engine" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group > athttp://groups.google.com/group/google-appengine?hl=en. -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
