从DataNucleus / JDO v1版本迁移到v2的问题

时间:2014-12-20 01:18:24

标签: java google-app-engine jdo datanucleus

我正在使用App Engine。我试图从DataNucleus / JDO v1升级到v2。 (JDO2.0到JDO3.0)

我的代码在v2下有以下问题(在v1中工作正常)

1 /查询的结果给出了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 /持久化对象后,出现序列化错误:

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();
}

在此之后,公司的序列化,将其发送到客户端会给出&#39; Type&#39; org.datanucleus.store.types.sco.simple.ArrayList&#39;未包含在可通过此SerializationPolicy&#39;

序列化的类型集中

我没有在互联网上的任何地方找到有关此迁移的提示或经验教训。

0 个答案:

没有答案