Get an Objectify Entity's Key

后端 未结 3 776
陌清茗
陌清茗 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-12 11:28

    The Key class in Objectify 4 has this method:

    public static  Key create(T pojo)
    

    so, if you already have read the entity (called category in this example) from the datastore, you can just call

    product.categoria = Key.create(category);
    

提交回复
热议问题