surinder-insonix / datanucleus-appengine

Automatically exported from code.google.com/p/datanucleus-appengine
0 stars 0 forks source link

Querying on inherited primary keys fails #182

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Have a class Entity with the @PrimaryKey Long Key;
2. Have a class Demand extending Entity
3. Try to query only on keys with a Query defined with: pm.newQuery("select
key from " + Demand.class)
4. Execute the query (I tried with a single parameter

What is the expected output? What do you see instead?
- I expect to get a List<Long> object containing the keys of the Demand
instances a query created only with pm.newQuery(Demand.class) can return
- In place, the JavaQueryCompiler throws a NullPointerException -- at
org.datanucleus.query.compiler.JavaQueryCompiler.getType(JavaQueryCompiler.java:
561)
-- see attached stack trace.

What version of the product are you using? On what operating system?
- WindowsXP
- AppEngine Java 1.3.0
- Datanucleus 1.0.4.1

Please provide any additional information below.
- Before Max Ross fixed the issue 25
(http://code.google.com/p/datanucleus-appengine/issues/detail?id=25),
filtering on inherited attributes failed.
- If the main issue is fixed, maybe the small part related to query on key
still exists...
- For now, my workaround is to extract the key from the selected (full)
entities. This is not efficient but I can live with it for a while ;)

A+, Dom

Original issue reported on code.google.com by dominiqu...@gmail.com on 5 Jan 2010 at 5:41

Attachments:

GoogleCodeExporter commented 8 years ago
Dom,

I've constructed my own version of your example and it's working for me.  I 
noticed 
in your logs that your query looks like this:

Select demand(s) with: SELECT id FROM class twetailer.dto.Demand WHERE ownerKey 
== attributeValue PARAMETERS Long attributeValue ORDER BY creationDate desc 
RANGE 0,1

Note that you have "class twetailer.dto.Demand" as opposed to just 
"tweatiler.dto.Demand"  This is the string from of Demand.class, which is not 
what 
you want.  I suspect if you change Demand.class to Demand.class.getName() this 
will 
work fine.  Can you please give that a try?

Thanks,
Max

Original comment by max.r...@gmail.com on 6 Jan 2010 at 5:39

GoogleCodeExporter commented 8 years ago
My bad! I should have catched the typo myself, especially because it's correctly
documented on
http://code.google.com/appengine/docs/java/datastore/queriesandindexes.html. It
appears I thought the usual Query creation was just updated with a prefix and I 
did
not see the explicit call to getName()!!!

Thanks for the clarification.
A+, Dom

Original comment by dominiqu...@gmail.com on 7 Jan 2010 at 6:08

GoogleCodeExporter commented 8 years ago

Original comment by max.r...@gmail.com on 7 Jan 2010 at 6:00