【发布时间】:2014-07-23 07:52:15
【问题描述】:
我会解释一下情况。我遵循了这两个伟大的教程:
但是,它们解释了如何为 Google Cloud Endpoint 创建 API,实体之间相互独立。所以 API 类看起来像这样:
package com.example.mobileassistant;
import javax.persistence.Entity;
import javax.persistence.Id;
/**
* Offer entity.
*/
@Entity
public class Offer {
@Id
private String offerId;
private String title;
private String description;
private String imageUrl;
.... (With Getter and Setter)
}
我的问题是:如何创建一个具有另一个父实体的类? 就像实体轮子一样,带有父汽车。我无法与其父实体创建关系(带有注释)!
我试过了,但它似乎不起作用(外键):
package com.example.mobileassistant;
import javax.jdo.annotations.ForeignKey;
import javax.persistence.Entity;
import javax.persistence.Id;
/**
* Offer entity.
*/
@Entity
public class Wheel {
@Id
private String Id;
@ForeignKey
private String parent_id;
private String title;
private String description;
.... (With Getter and Setter)
}
【问题讨论】:
标签: google-app-engine jpa google-cloud-endpoints google-cloud-datastore