appengine - java持久性

发布于 2024-07-19 05:22:28 字数 1829 浏览 6 评论 0原文

我有 3 个具有关系的类:

  • 成员 1-n 跟踪器
  • 1-n 跟踪器

链接具有拥有的一对多双向关系的

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Member {
        @PrimaryKey
        @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
        private Key key;

        @Persistent(mappedBy = "member")
        private List<Tracker> trackers;

}

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Link {
        @PrimaryKey
        @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
        private Key key;

        @Persistent(mappedBy = "link")
        private List<Tracker> trackers;

}

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Tracker {
        @PrimaryKey
        @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
        private Key key;

        @Persistent
        private Member member;

        @Persistent
        private Link link;

} 

我创建了一个新的跟踪器:

member = new Member();
member.name = "blah";

link = new Link();
link.url = "http://blahblah.blah";

tracker = new Tracker();
tracker.setMember(member);
tracker.setLink(link);

pm.makePersistent(tracker);//error

它抛出

The class "The class "zodpob.model.Tracker" is not persistable. This
means that it either hasnt been enhanced, or that the enhanced version
of the file is not in the CLASSPATH (or is hidden by an unenhanced
version), or the Meta-Data/annotations for the class are not found."
is not persistable. This means that it either hasnt been enhanced, or
that the enhanced version of the file is not in the CLASSPATH (or is
hidden by an unenhanced version), or the Meta-Data for the class is
not found.

什么是“增强”意味着什么?

如果我坚持一个没有关系的课程,效果很好

I have 3 class with relation:

  • Member 1-n Tracker
  • Link 1-n Tracker

with owned one-to-many bidirectional relationship

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Member {
        @PrimaryKey
        @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
        private Key key;

        @Persistent(mappedBy = "member")
        private List<Tracker> trackers;

}

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Link {
        @PrimaryKey
        @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
        private Key key;

        @Persistent(mappedBy = "link")
        private List<Tracker> trackers;

}

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Tracker {
        @PrimaryKey
        @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
        private Key key;

        @Persistent
        private Member member;

        @Persistent
        private Link link;

} 

I create a new tracker:

member = new Member();
member.name = "blah";

link = new Link();
link.url = "http://blahblah.blah";

tracker = new Tracker();
tracker.setMember(member);
tracker.setLink(link);

pm.makePersistent(tracker);//error

it throws

The class "The class "zodpob.model.Tracker" is not persistable. This
means that it either hasnt been enhanced, or that the enhanced version
of the file is not in the CLASSPATH (or is hidden by an unenhanced
version), or the Meta-Data/annotations for the class are not found."
is not persistable. This means that it either hasnt been enhanced, or
that the enhanced version of the file is not in the CLASSPATH (or is
hidden by an unenhanced version), or the Meta-Data for the class is
not found.

what is "enhanced" mean?

if i persistent a class with no relation, it's work well

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尸血腥色 2024-07-26 05:22:28

确保您使用的是 DataNucleus 插件...

这是他们的网站...

链接文本

。 ..以下是如何将其安装到 Eclipse IDE...

链接文本

...这里是与 JDO 一起使用它的教程...

链接文本

我希望有所帮助,祝你好运。

Make sure you're using the DataNucleus plugin....

Here is their site...

link text

...here is how to install it on to the Eclipse IDE...

link text

...and here is a tut for using it with JDO....

link text

I hope that helps and good luck.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文