Android Room Persistence library entity with AutoValue

前端 未结 4 1109
北海茫月
北海茫月 2021-02-13 19:45

Is it possible to use both Room persistence library\'s @Entity with AutoValue\'s @AutoValue and builder on the same POJO? How should i do it?

4条回答
  •  北恋
    北恋 (楼主)
    2021-02-13 20:11

    Released in 2.1.0-alpha01!

    Note that you have to add the @CopyAnnotations annotation for it to work

    Auto Value: Room now supports declaring AutoValue annotated classes as entities and POJOs. The Room annotations @PrimaryKey, @ColumnInfo, @Embedded and @Relation can now be declared in an auto value annotated class’ abstract methods. Note that these annotation must also be accompanied by @CopyAnnotations for Room to properly understand them.

    see the release notes

提交回复
热议问题