DataNucleus JIRA is now in read-only mode. Raise any new issues in GitHub against the plugin that it applies to. DataNucleus JIRA will remain for the foreseeable future but will eventually be discontinued
Issue Details (XML | Word | Printable)

Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Dmitry J. Voronov
Votes: 0
Watchers: 1

If you were logged in you would be able to see more operations.
DataNucleus Store RDBMS

Complete-table inheritance with query.setResult(...) throws NPE

Created: 08/Apr/11 08:50 PM   Updated: 09/May/11 10:00 AM   Resolved: 09/May/11 10:00 AM
Component/s: Queries
Affects Version/s: 3.0.0.m3
Fix Version/s: 3.0.0.m4

File Attachments: 1. Zip Archive (2 kB)

Datastore: PostgreSQL
Severity: Development

 Description  « Hide
Hello, Andy! :) Congratulations with 3.0.0!

I've got the following issue.
My "Zone" class inherits "AbstractBean" class using complete-table strategy.

When I try to create aggregated query with it I always get an NPE...
Everything goes just fine when I use other inheritance strategy OR don't use aggregates
(just to be sure that the mappings/settings are ok I've tested it a hundred times...)

Query = SELECT sum(id) FROM net.retn.iris.domain.geo.Zone

2011-04-08 21:52:00,543 ERROR [main] ( - Unexpected error during modification
at org.datanucleus.api.jdo.JDOQuery.execute(
at net.retn.iris.server.Tests$
at net.retn.iris.server.Tests$

The key to solve the problem is on line 300 of the, where you say:
If "complete-table" then we'll do it this way....

And clsMapping parameter is null, because it is "datastoreCompilation.getResultDefinitionForClass()" from JDOQLQuery.class:
Always null when I declare the result statement:

        if (result != null)
            datastoreCompilation.setResultDefinition(new StatementResultMapping());
            datastoreCompilation.setResultDefinitionForClass(new StatementClassMapping());

        // Generate statement for candidate(s)
        SQLStatement stmt = null;
            stmt = RDBMSQueryUtils.getStatementForCandidates(null, candidateCmd,
                datastoreCompilation.getResultDefinitionForClass(), ec, candidateClass, subclasses, result, null,

Sorry for posting so much info, but I don't get the idea why the inheritance strategy for "Zone" class
is "complete-table". I thought it is declared for AbstractBean class only.
And I cannot offer any patch without your vision of the situation...

Should I just add null-check? Or maybe I should never call getStatementForCandidates() without StatementClassMapping available?
Or maybe it's my fault and I should just re-declare inheritance-strategy for every class beyond my AbstractBean?


Sort Order: Ascending order - Click to sort in descending order
Andy Jefferson added a comment - 09/Apr/11 08:44 AM
Testcase as per the docs?

Dmitry J. Voronov added a comment - 11/Apr/11 11:34 AM - edited
Test-case is attached. I used annotations, so inform me pls if "package.jdo" is still required.

Andy Jefferson added a comment - 19/Apr/11 06:01 PM
No idea what your comments about AbstractBean, Zone class mean since there are no such classes in the test.

Aggregate queries typically won't be doable with complete-table, or at least not doable in a single query when there are subclasses. They ought to be doable when only one classin that inheritance tree has objects.

SVN trunk may work on that specific case now

Dmitry J. Voronov added a comment - 20/Apr/11 01:37 PM
I'm sorry for the class naming, I just followed the provided example more than I needed to. In the testcase AbstractBean corresponds to "A" class, and the mentioned Zone class stands for "B". "B" class can have direct instances. It didn't declare itself as complete-table inheritance root, as per the docs.

Andy Jefferson added a comment - 20/Apr/11 02:35 PM
Declaring the root table in an inheritance tree as "complete-table" means ALL classes in that tree use "complete-table", hence B does by definition

Andy Jefferson added a comment - 09/May/11 10:00 AM
Marking as fixed since that test passes