如何模拟GAEJ中的实体关系? [英] How to model entity relationships in GAEJ?

查看:121
本文介绍了如何模拟GAEJ中的实体关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道 - 例如高度赞赏 -

p>

- 一对多

- 多对多



我搜索了整个网页,没有发现Java的所有指南和教程都是关于Python的。



我从 article ,在Python中,关系使用 ReferenceProperty 建模。然而,我在Javadoc参考文献中没有发现任何关于这个类的内容。



另外,在 article 他们讨论了以下内容:


目前Java用户的工具不足,主要是由于App Engine的Java平台的相对新颖性。


$ b $然而,这是2009年编写的。

最后,我最终使用每个实体的祖先路径建模关系。我发现后面这种方法有问题,并限制了应用程序的可扩展性。



您可以引导我将相应的Java类引导到Python的 ReferenceProperty <强>班?或者,您能否给我举一个例子,说明如何使用java datastore低级API在AppEngine中建立关系。



预先感谢您的帮助。

解决方案

在GAE / J中创建实体之间的关系取决于您使用的db API:


  1. JDO:实体关系

  2. JPA:查看文档 .com / p / objectify-appengine / wiki / IntroductionToObjectify#Single-Value_Relationshiprel =nofollow>单值关系。 低级API:将一个实体的Key作为属性添加到另一个实体:请参阅属性类型



I would like to know -an example is highly appreciated-

How to model relationships in Google App Engine for Java?

-One to Many
-Many to Many

I searched allover the web and I found nothing about Java all guides and tutorials are about Python.

I understood from this article that in Python the relationships are modeled using ReferenceProperty. However, I found nothing about this class in the Javadoc reference.

Furthermore, in this article they discussed the following:

there's currently a shortage of tools for Java users, largely due to the relative newness of the Java platform for App Engine.

However, that's was written in 2009.

At the end, I ended up modeling the relationships using the ancestor path of each entity. I discovered afterwords that this approach has problems and limit the scalability of the app.

Can you please guide me to the equivalent Java class to the Python's ReferenceProperty class? Or can you please give me an example of how to model the relationships in AppEngine using the java datastore low-level API.

Thanks in advance for your help.

解决方案

Creating relationships between entities in GAE/J depends on db API that you are using:

  1. JDO: entity relationships.

  2. JPA: see docs.

  3. Objectify: single-value relationships.

  4. Low-level API: add a Key of one Entity as a property to another Entity: see property types.

这篇关于如何模拟GAEJ中的实体关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆