2012-01-28 74 views
1

我收到以下错误消息:org.datanucleus.exceptions.NucleusUserException:对象管理器已经关闭

org.datanucleus.exceptions.NucleusUserException:对象管理器已经关闭

我已经读了我能找到的所有东西,但我仍然不明白 是什么造成它。我即将放弃并切换到SQL数据库,如果我不能解决这个简单的问题 。是的,我关闭时:

静态无效persistAll(对象[]的OBJ){

PersistenceManager pm = PMF.get().getPersistenceManager(); 
Transaction tx = pm.currentTransaction(); 
try { 
    tx.begin(); 
    for (Object o : objs) 
    pm.makePersistent(o); 
    //pm.makePersistentAll(objs); 
    tx.commit(); 
} finally { 
    if (tx.isActive()) 
    tx.rollback(); 
    pm.close(); 
} 

}

我做了我的东西可拆卸的,我已经脱离我的对象,其中 我以为我必须。我现在能做什么???我完全卡在这一个! DataNucleus,请帮忙!

JG

我曾尝试加入商店的名单<>到默认域提取组和调试我的应用程序,当我从码头收到以下警告错误。当我取东西时,我将不得不尝试“触摸”字段。 (?)

Jan 29, 2012 1:29:30 PM org.datanucleus.store.appengine.MetaDataValidator warn 
WARNING: Meta-data warning for com.foobar.foo.Store.sales: The datastore does not support joins and therefore cannot honor requests to place related objects in the default fetch group. The field will be fetched lazily on first access. You can modify this warning by setting the datanucleus.appengine.ignorableMetaDataBehavior property in your config. A value of NONE will silence the warning. A value of ERROR will turn the warning into an exception. 
Jan 29, 2012 1:29:30 PM org.datanucleus.store.appengine.MetaDataValidator warn 
WARNING: Meta-data warning for com.foobar.foo.Store.shipments: The datastore does not support joins and therefore cannot honor requests to place related objects in the default fetch group. The field will be fetched lazily on first access. You can modify this warning by setting the datanucleus.appengine.ignorableMetaDataBehavior property in your config. A value of NONE will silence the warning. A value of ERROR will turn the warning into an exception. 
Jan 29, 2012 1:29:30 PM org.datanucleus.store.appengine.MetaDataValidator warn 
WARNING: Meta-data warning for com.foobar.foo.Store.users: The datastore does not support joins and therefore cannot honor requests to place related objects in the default fetch group. The field will be fetched lazily on first access. You can modify this warning by setting the datanucleus.appengine.ignorableMetaDataBehavior property in your config. A value of NONE will silence the warning. A value of ERROR will turn the warning into an exception. 

我正在从一个pm.makePersistent(store)NullPointerException即使我已经与存储调试检查不为空(但是,由于默认提取组无法正常工作,可能是这其中的一些子场不知何故(?)

回答

5

我怀疑你的问题涉及试图访问一个字段的值是懒惰加载如果你在PersistenceManager关闭后,这是一个错误,例如,懒惰加载是JDO拥有关系中子对象的默认设置 请确保在关闭pm和分离对象之前获取或访问(“touch”)这些内容。一个拥有的一对一关系,您还可以将子字段添加到“默认获取组”中,以便检索并加载父级。

还有更多的讨论在这个位置:http://code.google.com/appengine/docs/java/datastore/jdo/relationships.html#Owned_One_to_One_Relationships

+0

谢谢您的回复,但如上图所示,App Engine是不是让我使用默认获取组对我的列表<>对象属性。我确实碰到了List <>,甚至将它分开,所以我不知道为什么当我pm.makePersistent()时我得到一个NullPointerException。任何帮助不胜感激。 JG – johngoche9999 2012-01-29 13:20:49

+1

是的,如果拥有m:1拥有关系,您将看到'不支持连接'的警告,并且不能使用子集合的默认获取组规范。 (对不起,我错过了你的描述)。因此,您必须在关闭pm之前显式访问集合中的子项 - 以及您需要访问的子对象中任何延迟加载的字段。 – 2012-01-29 23:31:19

相关问题