To update your existing entities to the new entity schema, you would
need to rewrite your existing entities (create new w/ same fields and
delete old).

To find the existing older entities, you could use the low level API
(DatastoreService) to fetch Entity
instances for your entity Kind and then use
getProperty(java.lang.String propertyName)
to return an Object which you would check the instanceOf, and then
create the new, delete, etc...

Note that you could do this on a "need only" basis, that is as each
older entity is
fetched.

FetchOptions fetchOptions = FetchOptions.Builder.withDefaults();
QueryResultList<Entity> results =
datastore.prepare(yourQuery).asQueryResultList(fetchOptions);
for (Entity entity : results) {
    Object cf = entity.getProperty("ID");
    if (cf instanceOf Integer) {
        ...
    }
}



On Jul 7, 8:40 pm, Jamie <ja...@mapstagram.com> wrote:
> I am indeed using JDO so I'm kinda bummed that a simple schema change
> like this is causing problems.
>
> Haven't used Objectify before but it sounds like it might do what I
> need.  I'm simply changing the type of a field/property (not part of
> the key) from Integer to String.  The issue is I have a LOT of
> existing entries, so I need to figure out the best way to store new
> entities using String for that property, but still be able to read old
> entities that have that value stored as an Integer.
>
> Sounds like Objectify might be my only choice?  I had another idea
> which involved using a new property with type String.  That way, new
> entities would have the new property filled, while old entities would
> have the original property filled.  The application code would need to
> handle this.  Kinda ugly and hackish though.
>
> On Jul 6, 4:34 pm, Jeff Schnitzer <j...@infohazard.org> wrote:
>
>
>
>
>
>
>
> > On Wed, Jul 6, 2011 at 12:56 PM, jMotta <jayrmo...@gmail.com> wrote:
> > > *
> > > *
> > > *Jeff*,
>
> > > You've said: "Objectify will let you change the field type to a String and
> > > do the right thing out of the box.", how?
>
> > > I know that's possible through @AlsoLoad annotation to override the 
> > > default
> > > behavior of binding properties based on the member name. But what I
> > > understood about his need is that actually he have entities whose the
> > > property names are equals but with different object types as values. So, 
> > > the
> > > only class shared in the String vs Long hierarchy will be Object.
>
> > The conversion process will merrily convert just about anything to a String.
> >  So going from Long -> String is easy.  The other way 'round, you would need
> > to use the @AlsoLoad mechanism.
>
> > Jeff

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to