Jamie,

I don't know if get it right, but if it's part of the key it is not possible
to change.

If this property is not part of the key, then you'll have to deal with it.
Probably you're using some persistence framework such as JDO, JPA or
Objectify. These are probably trying to bind the properties found in the
datastore Entity object into somekind of DTO / POJO through reflection and
then getting this class cast exception.

Even it being allowed to use multiple type values in a given property, I
don't think it's a good idea. I would recommend you to build something to
migrate your old entities to the new model, maybe using datastore low-level
API to have more control over what's done.

If the class cast exception is been thrown somewhere else than the
persistence framework (I bet it's not!), you can do some treatment over the
type object retrieved or do as I said about running some code to adapt your
entities to your new "schema".

*Jayr Motta*
Software Developer
*
*
I'm  on 
BlackBeltFactory.com<http://www.blackbeltfactory.com/ui#!User/jmotta/ref=jmotta>
!



On Wed, Jul 6, 2011 at 2:10 AM, Jamie <[email protected]> wrote:

>
> I'm currently storing an ID property as an Integer in the datastore.
> This ID is actually an ID from a third party API.  Recently they
> announced that this ID field will now be a String type.
>
> I understand that different entities of the same kind can have
> different properties as well as having the same property with
> different types.  This is fine for new entities that I save with the
> updated Java model, but how do I handle retrieval of old entities
> using this updated Java model?  I'm currently getting a
> ClassCastException ("java.lang.Long cannot be cast to
> java.lang.String") which is to be expected.
>
> What's the recommendation on how to handle this, as this would appear
> to be a common scenario?
>
> Thanks
>
> --
> 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
> [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-java?hl=en.
>
>

-- 
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 [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-java?hl=en.

Reply via email to