Android Room Persistence library entity with AutoValue

♀尐吖头ヾ 提交于 2020-01-01 04:24:10

问题


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?


回答1:


AFAIK, as of 1.0.0-alpha3, this is not possible. Room wants fields; AutoValue doesn't expose fields. Keep tabs on this feature request for progress in this area.




回答2:


This feature will be available in Room 2.1.0 https://issuetracker.google.com/issues/62408420#comment27




回答3:


Following this task, apparently they added support. I assume it will be possible in the future Room release (probably androidx.room version 2.0.0). Still not merged as part of 2.0.0-beta1 though




回答4:


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



来源:https://stackoverflow.com/questions/44869545/android-room-persistence-library-entity-with-autovalue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!