2012-01-28 179 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

相關問題