在 App Engine+Endpoint+GCM Backend 中进行对象化。 Children & parent
Objectify in App Engine+Endpoint+GCM Backend. Children & parent
我创建了我的 "App Engine Backend with Google Cloud Messaging" 模板,比如 this one
然后我让我的实体 class 成为员工。和 entety class 经理。
@Entity
public class Employee {
@Id
Long id;
@Index
private String regId;
@Index
private String email;
/*
@Index
@Load
Ref <Manager> managerRef;
*/
@Index
@Parent
Key <Manager> managerKey;
public Employee (){};
public void setRelationKey(Key<Manager> managerKey){
this.managerKey = managerKey;
}
public Key<Manager> getRelationKey(){
return managerKey;
}
public Long getId(){
return id;
}
public String getRegId() {
return regId;
}
public void setRegId(String regId) {
this.regId = regId;
}
public String getEmail() {
return email;
}
public void setEmai(String email) {
this.email = email;
}
}
为了处理数据,它使用 objectify。所以不会有领导经理的员工群体。我放
`@Index
@Parent
Key <Manager> managerKey;`
在员工中。然后我从 java class 生成云端点:EmployeeEndpoint 和 ManagerEndpoint
然后构建 -> 将模块部署到 AppEngine
并给出 BUILD FAILED
失败:构建失败,出现异常。
出了什么问题:
任务“:backend:appengineEndpointsGetClientLibs”执行失败。
There was an error running endpoints command get-client-lib: Parameterized type com.googlecode.objectify.Key
< com.example.Operator.myapplication.backend.Manager> not supported.
尝试:
运行 使用 --stacktrace 选项获取堆栈跟踪。 运行 使用 --info 或 --debug 选项以获得更多日志输出。
希望得到您的帮助。
我从 this
找到了解决方案
您必须使用 @ApiResourceProperty 注释您的方法并将其忽略的属性设置为 true,如下面的代码所示:
@Entity
public class Employee {
/** */
/*
public static Key<Employee> key(long id) {
return Key.create(Employee.class, id);
}
*/
@Parent
Key<ManagerManager> managerKey;
@Id
Long id;
@Index
private String regId;
@Index
private String email;
/*
@Index
@Load
Ref <Manager> managerRef;
*/
public Employee (){};
@ApiResourceProperty(ignored = AnnotationBoolean.TRUE)
public void setRelationKey(Key<ManagerManager> managerKey){
this.managerKey = managerKey;
}
@ApiResourceProperty(ignored = AnnotationBoolean.TRUE)
public Key<ManagerManager> getRelationKey(){
return managerKey;
....
构建成功
我创建了我的 "App Engine Backend with Google Cloud Messaging" 模板,比如 this one 然后我让我的实体 class 成为员工。和 entety class 经理。
@Entity
public class Employee {
@Id
Long id;
@Index
private String regId;
@Index
private String email;
/*
@Index
@Load
Ref <Manager> managerRef;
*/
@Index
@Parent
Key <Manager> managerKey;
public Employee (){};
public void setRelationKey(Key<Manager> managerKey){
this.managerKey = managerKey;
}
public Key<Manager> getRelationKey(){
return managerKey;
}
public Long getId(){
return id;
}
public String getRegId() {
return regId;
}
public void setRegId(String regId) {
this.regId = regId;
}
public String getEmail() {
return email;
}
public void setEmai(String email) {
this.email = email;
}
}
为了处理数据,它使用 objectify。所以不会有领导经理的员工群体。我放
`@Index
@Parent
Key <Manager> managerKey;`
在员工中。然后我从 java class 生成云端点:EmployeeEndpoint 和 ManagerEndpoint
然后构建 -> 将模块部署到 AppEngine
并给出 BUILD FAILED 失败:构建失败,出现异常。
出了什么问题: 任务“:backend:appengineEndpointsGetClientLibs”执行失败。
There was an error running endpoints command get-client-lib: Parameterized type com.googlecode.objectify.Key < com.example.Operator.myapplication.backend.Manager> not supported.
尝试: 运行 使用 --stacktrace 选项获取堆栈跟踪。 运行 使用 --info 或 --debug 选项以获得更多日志输出。
希望得到您的帮助。
我从 this
找到了解决方案您必须使用 @ApiResourceProperty 注释您的方法并将其忽略的属性设置为 true,如下面的代码所示:
@Entity
public class Employee {
/** */
/*
public static Key<Employee> key(long id) {
return Key.create(Employee.class, id);
}
*/
@Parent
Key<ManagerManager> managerKey;
@Id
Long id;
@Index
private String regId;
@Index
private String email;
/*
@Index
@Load
Ref <Manager> managerRef;
*/
public Employee (){};
@ApiResourceProperty(ignored = AnnotationBoolean.TRUE)
public void setRelationKey(Key<ManagerManager> managerKey){
this.managerKey = managerKey;
}
@ApiResourceProperty(ignored = AnnotationBoolean.TRUE)
public Key<ManagerManager> getRelationKey(){
return managerKey;
....
构建成功