Issue with using the Google Datastore query console

322 views Asked by At

I have been implementing an app using appengine and am also using JDO.

In one of my entity classes I have a int property:

@Extension(vendorName="datanucleus", key="gae.unindexed", value="true")
@Persistent
int numberToStore;

I was able to store the entity and access this property without any issues.

However, I decided to use the datastore query console and update the value of the numberToStore property from 4 to 5. The type in the "Edit Entity" screen of the console has always been "A number". I now get the following exception in my log whenever I try to access the entity from the datastore:

com.google.api.server.spi.SystemService invokeServiceMethod: cause={0} java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Double at com.google.appengine.datanucleus.TypeConversionUtils$5.apply(TypeConversionUtils.java:121) at com.google.appengine.datanucleus.TypeConversionUtils$5.apply(TypeConversionUtils.java:119)

Why is this issue occurring? Does updating the entity property value from the admin console cause the underlying type of the property to change. Also how can I now undo this type change to this specific property in the entity.

1

There are 1 answers

0
Ed Davisson On BEST ANSWER

If you include a decimal point in the value (e.g. 5.0 instead of 5), it will be treated as a float.

Alternatively, you can use the Datastore Viewer available in the App Engine Admin Console (https://appengine.google.com -> Datastore Viewer) to change the type of the value back to a float.

Note that changing the type of a property requires two saves: once to set the property type to null and once to change it to float.