Issues with migratiing from DataNucleus/JDO version v1 to v2

这一生的挚爱 提交于 2019-12-25 01:15:57

问题


I am using App Engine. I'm trying to upgrade from DataNucleus/JDO version v1 to v2. (JDO2.0 to JDO3.0)

My code however has following problems under v2 (and works fine in v1)

1/ The result from a query gives a nullPointerException.

Query q = pm.newQuery(Company.class, query);
List<Company> companies = (List<Company>) q.execute(); 
// this should return a non-empty list
for (Company company: companies) -> NullPointerException

2/ After persisting an object, I get a serialization error :

public final class PMF {
    private static final PersistenceManagerFactory pmfInstance =
        JDOHelper.getPersistenceManagerFactory("transactions-optional");
    private PMF() { pmfInstance.setDetachAllOnCommit(true); }
    public static PersistenceManagerFactory get() { return pmfInstance; }
}

Company company = new Company(...);

PersistenceManager pm = PMF.get().getPersistenceManager();
try {
    pm.currentTransaction().begin();
    pm.makePersistent(company);
    pm.currentTransaction().commit();
    // because of setDetachAllOnCommit(true), the object should be detached..
} catch (Exception e) {
} finally {
    if (!pm.isClosed()) pm.close();
}

After this, serialization of company, sending it to the client gives 'Type 'org.datanucleus.store.types.sco.simple.ArrayList' was not included in the set of types which can be serialized by this SerializationPolicy'

I'm not finding anywhere on the internet tips or lessons learned on this migration.

来源:https://stackoverflow.com/questions/27576049/issues-with-migratiing-from-datanucleus-jdo-version-v1-to-v2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!