pm.newObjectIdInstance returns null

#1

I am on an emergency upgrade mission. Our production odb file (version 1.0.4) currently corrupts when written to. Importing to 2.6.8. has seemed to fix the corruption problem. So....I am in the middle of testing a 2.6.8 upgrade from 104se_2522. It was plugged in to the existing legacy code (2005'ish). Trying to modify as little as possible. I am having trouble with the following:(names have been simplified)

public MyClass retrieveMyClass(String oid, boolean makeTransient, MyContext context) throws PersistenceLayerException {
       MyClass myclass = null;
       try{
              Object objectid = pm.newObjectIdInstance(AFPhysicalPart.class, oid);
              physpart = (MyClass) pm.getObjectById(objectid, false);
              if(makeTransient) myclass= (MyClass) myclass.clone();
              //if(makeTransient) pm.makeTransient(myclass);
        }catch (JDOException jdoe){
        }
        return myclass;
    }

objectid is coming back as null.  Does this problem seem obvious to you?

Thanks
Brian
(There is a complete re-write in the works but not ready for release)

#2

The first thing that PersistenceManager's newObjectIdInstance does is to search for an ID class, and if this fails a null is returned.

You can check that operation directly:

Class c = getObjectIdClass((AFPhysicalPart.class)

does it return null?

But are you sure that newObjectIdInstance returns null? Maybe an exception is thrown? Can you post the stack trace?

Note that ObjectDB 1.x (unlike ObjectDB 2.x) supports only numeric ids so it is unclear how your converted database can have string ids.

ObjectDB Support
#3

After further checking of newObjectIdInstance implementation in ObjectDB 2.x it seems that it is limited to classes in which an ID class or a primary key is defined explicitly by the application.

Please try a new build 2.6.8_03 that includes an attempt to fix  this limitation.

ObjectDB Support

Reply