Objectify with Cloud Endpoints

后端 未结 4 806
暖寄归人
暖寄归人 2021-02-01 22:17

I am using appengine cloud endpoints and objectify. I have previously deployed these endpoints before and now I am updating them and it is not working with Objectify. I have m

4条回答
  •  长发绾君心
    2021-02-01 22:53

    I came up with the following solution for my project:

    @Entity
    public class Car {
    
        @Id Long id;
    
        @ApiResourceProperty(ignored = AnnotationBoolean.TRUE)
        Key driver;
    
        public Key getDriver() {
            return driver;
        }
    
        public void setDriver(Key driver) {
            this.driver = driver;
        }
    
        public Long getDriverId() {
            return driver == null ? null : driver.getId();
        }
    
        public void setDriverId(Long driverId) {
            driver = Key.create(Driver.class, driverId);
        }
    }
    
    @Entity
    public class Driver {
        @Id Long id;
    }
    

    I know, it's a little bit boilerplate, but hey - it works and adds some handy shortcut methods.

提交回复
热议问题