google-app-engine


Appengine: ClassCastException in query with string of leng


In my Google App Engine project I got an unexpected exception:
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract java.lang.String org.learnjapanese.client.NewAccount.login(java.lang.String,java.lang.String) throws java.lang.IllegalArgumentException' threw an unexpected exception: java.lang.ClassCastException: java.lang.Character cannot be cast to com.google.appengine.api.datastore.Key
at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:378)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:581)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:188)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:224)
This is my JPA-code:
#Entity
public class Test {
#Id
String id;
}
And this is the application code:
EntityManager manager = EMF.get().createEntityManager();
Query q = manager.createQuery("select x from Test x where id = '12'");
List l = q.getResultList(); // No problem here
q = manager.createQuery("select x from Test x where id = '1'");
l = q.getResultList(); // java.lang.ClassCastException occurs here.
It turns out that a query with a String of length 1 causes the exception, while the String with length 2 does not. Can anyone explain what is going on here? Is there a workaround?
In Java a single character enclosed in single quotes is interpreted as a char literal. It looks like this is what's happening when you use '1' in your statement. The stack trace is talking about an instance of java.lang.Character which is what you would get if a char was auto-boxed. Sounds like a bug in the framework you're using.

Related Links

Using QuerySplitter in Google Datastore to load chunks of a known size
Can you explain what the app engine context interface is?
How to ensure that my entity will never be an orphan?
GAE custom Go runtime - internal.flushLog error
Google Datastore - Search Optimization Technique
Can't lease tasks by service account
Why custom domain “myapp.com” which replaces “myapp.appspot.com” took so long to load when comparing to “myapp.appspot.com”?
Does objectify have a get_or_insert equivalent
Custom domain from google not routing to App engine site
Unable to stop or delete datalabs environment on Google Cloud Platform
Is there a way to interactively create a new Datastore entity kind for Go GAE apps?
Is IP address from GoogleAppEngine URLFetch in same project static?
Index Disadvantages
Communications link failure when connect to Google Cloud SQL(second gen) only from prod
How do I add a Google Cloud Endpoints Module to my Android project in IntelliJ?
Does anyone know how to configure grunt-gcloud?

Categories

HOME
oracle12c
deep-learning
awk
polymer
depth
serialization
socket.io
appcelerator
google-cloud-functions
static-site
rds
retrofit2
bing-maps
endeca
nancy
symmetricds
magnetic-cards
intershop
imessage
cfml
database-connection
href
react-toolbox
angular-routing
php-mysqlidb
epsilon
jquery-callback
comparator
beta
moses
shared
fragment-backstack
mat
android-things
vex
google-earth
eviews
kudu
clickjacking
joomla2.5
hibernate-search
watchman
graphhopper
sessionstorage
sim-card
css-position
google-data-api
sharp-snmp
oracle-service-bus
smoothstate.js
puredata
vaadin-elements
gitlist
geotiff
convex-optimization
remedy
aquamacs
amq
static-cast
jqchart
cpu-cache
py2neo
cd-burning
cvxpy
visual-studio-2008-sp1
chromium-os
centrifuge
tinkerpop3
mapinfo
ng-grid
delta
simevents
project-organization
yajsw
invoke-sqlcmd
mobiledoc-kit
assertion
grgit
gocql
iokit
fiware-monitoring
file-move
video-player
fuelcms
batik
iced-coffeescript
typeconverter
kubuntu
rrule
umlgraph
gamekit
crowd
structuremap3
nsmenu
with-statement
ignite-ui
jjaql
spring-remoting
vbe
maven-scm
gwt-openlayers
gtm-oauth2
jammer
windows-phone-8-sdk
nebula
android-icons
insert-id
mantle
chart-director
vfs
cuda-gdb
subproject
mapping-by-code
failing-tests
xui
globals
interprocess
pos-for-.net
skype4java
web-application-project
software-lifecycle

Resources

Encrypt Message