Google AppEngine JDO 持久性 FK 数组
我希望有人看到这个。我在谷歌上没有找到任何线索。
我使用 Google AppEngine 和 JDO 来保存我的对象。
我有两个对象,父对象和子对象。每个 Parent 有 n 个 Child 对象。
我最初将 Child 对象存储在 Parent 类的 ArrayList 数据成员中。
持久化 Parent 对象时,出现异常“java.lang.UnsupportedOperationException:不支持 FK 数组”。
我将其归咎于我存储了多个子键引用,因此对其进行了更改,以便子对象存储对父对象的键引用。这样,每个 Child 对象只有一个键引用,而不是每个 Parent 对象有 n 个键引用。
然而,在保留 Parent 对象时,仍然会引发异常。所以我怀疑我对这个异常的可能原因是错误的。
有谁见过这个异常或者知道它意味着什么?
I'm hoping someone's seen this. I've found no clues on Google.
I'm using Google AppEngine with JDO to persist my objects.
I have two objects, Parent and Child. Each Parent has n Child objects.
I initially stored the Child objects in an ArrayList data member in the Parent class.
I got the exception "java.lang.UnsupportedOperationException: FK Arrays not supported" when persisting the Parent object.
I put this down to my storing more than one Child key references, so changed it around so that the Child objects store key references to the Parent object instead. In this way, there is only one key reference per Child object instead of n key references per Parent object.
Yet the exception still gets thrown when persisting the Parent object. So I suspect I was mistaken about the probable cause of this exception.
Has anyone seen this exception or know what it means?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据 DataNucleus 的说法,很多东西都是默认持久化的……他们甚至在博客中对 google 应用引擎网站中的手册进行了投诉,该手册说您需要将字段显式标记为 @Persistent。
According to DataNucleus a lot of things are persisted by default... and they even had a complaint in their blog about the manual in the google app engine site, which said that you need to explicitly mark fields as @Persistent.
我知道出了什么问题了。
它并不是在抱怨我的 ArrayList。
我的父类有一个数组数据成员,我没有在上面添加注释。在没有注释的情况下,默认情况下会保留数组。
我添加了注释
@NotPercient
这解决了我的问题。I figured out what was wrong.
It wasn't complaining about my ArrayList.
My Parent class had an array data member that I hadn't put an annotation on. Arrays are persisted by default in the absence of annotations.
I added the annotation
@NotPersistent
and this solved my problem.