【问题标题】:Objectify in App Engine+Endpoint+GCM Backend. Children & parent在 App Engine+Endpoint+GCM 后端中对象化。孩子和家长
【发布时间】:2023-03-23 23:18:01
【问题描述】:

我创建了我的“App Engine Backend with Google Cloud Messaging”模板,例如this one 然后我让我的实体类员工。和实体类经理。

 @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 类生成 Cloud Endpoint:EmployeeEndpoint 和 ManagerEndpoint

然后构建 -> 将 Modul 部署到 AppEngine

并给出 BUILD FAILED FAILURE:构建失败并出现异常。

  • 出了什么问题: 任务“:backend:appengineEndpointsGetClientLibs”执行失败。

    运行端点命令 get-client-lib 时出错:参数化类型 com.googlecode.objectify.Key 不支持。

  • 尝试: 使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。

    希望能得到您的帮助。

【问题讨论】:

    标签: android google-app-engine google-cloud-messaging google-cloud-endpoints objectify


    【解决方案1】:

    我从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;
       ....
    

    它构建成功

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多