JDO 不检索/持久化集合
我定义了以下数据模型类:
@PersistenceCapable
public class TestSerializableModelObj {
@Persistent(serialized="true", defaultFetchGroup="true")
private MyPOJO myField;
@Persistent(serialized="true", defaultFetchGroup="true")
private Collection<MyPOJO> myCollection;
// getter/setters
}
MyPOJO 只是一个实现可序列化的简单类。
当我通过 DataNucleus/JDO 持久化它并检索它时,我可以很好地读取 myField
,但是 myCollection
为空(尽管我之前将其设置为两个 MyPOJO 对象的向量)坚持下去)。
I have the following data model class defined:
@PersistenceCapable
public class TestSerializableModelObj {
@Persistent(serialized="true", defaultFetchGroup="true")
private MyPOJO myField;
@Persistent(serialized="true", defaultFetchGroup="true")
private Collection<MyPOJO> myCollection;
// getter/setters
}
MyPOJO is just a simple class that implements Serializable.
When I persist this via DataNucleus/JDO and retrieve it I can read myField
just fine, but myCollection
is null (though I set it to be an Vector of two MyPOJO objects before persisting it).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
虽然我在问题中没有提到,但我使用 DB4O 作为数据库引擎。我把它换成了 NeoDatis,神奇的是我所有的问题都消失了,我的所有测试用例都完美运行。
不知道为什么 DB4O 不喜欢我,此时我不在乎,NeoDatis “Just Works”,而 DB4O 则不然。
事实上,我花了 3 天的时间来解决 DB4O 可能出现的所有问题,并在 5 分钟内完成了我在 NeoDatis 下工作的 3 天中创建的每个测试用例。
Although I didn't mention it in the question, I was using DB4O as the database engine. I swapped it out for NeoDatis and magically all my problems went away, all my test cases worked perfectly.
Don't know why DB4O doesn't like me, and at this point I don't care, NeoDatis "Just Works", and DB4O doesn't.
In fact I spent 3 days fighting with every conceivable problem possible with DB4O and in 5 minutes had every test case I had created in those 3 days working under NeoDatis.