在python中考虑以下app-engine模型。
class Account(ndb.Model):
email = ndb.StringProperty()
nickname = ndb.StringProperty()
phone = ndb.IntegerProperty()
date = ndb.DateTimeProperty(auto_now_add=True)
class Invitation(ndb.Model):
sender = ndb.StructuredProperty(Account, required=True)
recipient = ndb.StructuredProperty(Account, required=True)
message = ndb.StringProperty()
date = ndb.DateTimeProperty(auto_now_add=True)
@classmethod
def get_recipient(cls, sender, date):
qry = Invitation.query(ndb.AND(Invitation.sender == sender, Invitation.date == date)).fetch(projection=['recipient']))
return qry
如何在Java中重写上面的代码?请注意,Account是一个合适的实体/模型 - 不受java EmbeddedEntity
强加的限制。另外,如果回复是JDO(请提供代码),the google site has a warning saying(我不明白):
多态查询。您无法执行要获取的类的查询 子类的实例。每个班级由一个单独的代表 数据存储区中的实体类型。
这个警告是否意味着我们可以用python做些事情,我们无法用app-engine上的java做什么?
答案 0 :(得分:1)
我想你想将你的app-engine后端转换为java的原因是因为谷歌Eclipse插件(GEP)创建了app-engine连接设备。如果是这种情况,那么通过在python中开发来节省的成本超过了使用GEP的好处。
您引用的警告与复合对象无关,这就是您的Account类对您的Invitation类的影响。
同样,除非你有明确的理由去参加java(除了GEP),否则你应该坚持使用Python。处理的事情要少得多。