【发布时间】:2012-08-18 23:45:26
【问题描述】:
我有这个问题,我有一个类的属性,它是一个 ArrayList,然后将这个类存储在 db4o 容器中会在服务器重新启动后清除列表。
具有 ArrayList 属性的类看起来有点像这样:
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; }
}
将类填充并存储到数据库中
if (planet.Moons == null)
{
planet.Moons = new ArrayList();
planet.Moons.Add(new Moon("MoonOne"));
planet.Moons.Add(new Moon("MoonTwo"));
Database.Store(planet);
}
只要服务器运行一切正常,列表是正确的,其中的值是正确的。该类的其他属性也正确无误。
重新启动服务器并清除列表。尽管类的其余部分仍然正确,并且数据库中的其他所有内容都很好,但只是列表由于某种原因被清除了。
有人知道为什么会发生这种情况吗?
【问题讨论】:
-
您知道 db4o 中的更新深度吗? community.versant.com/documentation/reference/db4o-8.1/java/…
-
增加UpdateDepth解决了这个问题,谢谢!