Issue Details (XML | Word | Printable)

Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: David Parks
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.
DataNucleus Store DB4O (ARCHIVED)

JDOHelper.getObjectId(...) in the query filter or setResult produces exceptions when the Candidate class contains no elements (e.g. the table is empty)

Created: 04/Feb/11 05:25 PM   Updated: 05/Feb/11 01:41 PM
Component/s: Queries
Affects Version/s: 2.0.1, 3.0.0.m1
Fix Version/s: None

Environment: Reproduced on: 2.2.1 & 3.0.0.m1

Forum Thread URL:,6532_lastpage,yes#33736
Datastore: DB4O
Severity: Production

 Description  « Hide
See forum post for longer explanation:,6532_lastpage,yes#33736

Reproduce issue:
        Thing thing = new Thing();
        Query query = pm.newQuery(Thing.class);
        Object rs = query.execute(); //Produces NullPointerException

(v.2.2.1) Line 132 []:
            Iterator iter = results.iterator();
            while (iter.hasNext())
                Object obj =;
                AbstractClassMetaData cmd = ec.getMetaDataManager().getMetaDataForClass(obj.getClass(), clr);
                DB4OUtils.prepareDB4OObjectForUse(obj, ec, cont, cmd, (DB4OStoreManager)ec.getStoreManager());
            return results;

When the candidate class has no instances (e.g. the table is empty), the results object here contains 1 object, a 'null'. This causes the null pointer exception in bold @ obj.getClass().
I believe the existence of this null object is also causing other problems when you call JDOHelper.getObjectId(this) in the filter.

Sort Order: Ascending order - Click to sort in descending order
David Parks added a comment - 05/Feb/11 01:40 PM
I mis-spoke, this is not an issue with an empty table. The test case given in the forum post clearly adds an element. The issue appears to be that the ultimate call to JDOHelper.getObjectId() in class JDOHelperGetObjectId fails because the JDOStateManager is null at the point that getObjectId is called, and it thus returns 'null'

David Parks added a comment - 05/Feb/11 01:41 PM
Reproduced on AccessPlatform for DB4O 2.2.1, 3.0.0.m1, and AccessPlatform for NeoDatis 2.2.1