2012-08-23 23 views
1

我有這個問題,其中有一個類是ArrayList的屬性,然後將此類存儲在db4o容器中,在服務器重新啓動後清除列表。具有ArrayList的屬性存儲db4o中的對象列表在重新啓動後清除

類看起來有點像這樣:

public class Planet 
{ 
    public string Name { get; set; } 
    public string Identifier { get; set; } 

    // Planet has an ArrayList property called Moons. 
    public ArrayList Moons { get; set; } 
} 

填充和storeing類的DB

if (planet.Moons == null) 
{ 
    planet.Moons = new ArrayList(); 
    planet.Moons.Add(new Moon("MoonOne")); 
    planet.Moons.Add(new Moon("MoonTwo")); 

    Database.Store(planet); 
} 

只要服務器在運行一切正常,列表是正確的,它裏面的值是正確的。該班的其他特性也是正確的和罰款。

重新啓動服務器並清除列表。儘管課程的其餘部分仍然正確,並且數據庫中的其他所有內容都很好,但由於某種原因,只有清單纔會被清除。

有沒有人有任何線索,爲什麼這可能會發生?

+2

您是否知道db4o中的更新深度? http://community.versant.com/documentation/reference/db4o-8.1/java/reference/Content/basics/update_concept/update_depth_in_action.htm – Gamlor

+0

增加UpdateDepth解決了這個問題,謝謝! – Alex

回答

0

Database.Store(planet);

這是商店或更新?我的意思是,在設置「月亮」成員之前從數據庫中檢索到「planet」對象,還是它是一個新實例化的對象?

你是否用簡單的嵌入式應用程序來試用它?

相關問題