Get an Objectify Entity's Key

后端 未结 3 782
陌清茗
陌清茗 2021-01-12 11:09

Dummy question.

I create my POJO Objectify entity (for example, \"Category\") and persist it.

Then I retrieve it via a query.

I want to use it in a

3条回答
  •  日久生厌
    2021-01-12 11:32

    For objectify 4 use:

    public Key getKey() {
       return Key.create(Foo.class, id);
    }
    

    Or if the entity has a @Parent

    public Key getKey() {
       return Key.create(parentKey, Bar.class, id);
    }
    

提交回复
热议问题