Android Room Persistence library entity with AutoValue
Asked Answered
S

5

13

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?

Sororicide answered 2/7, 2017 at 9:57 Comment(5)
I ran into problems with this and filed this feature request, so AFAIK as of 1.0.0-alpha3 this is still not possible.Gwyn
@Gwyn thanks. if you post it as answer, i will accept it.Sororicide
Added comment in the feature request, @Gwyn did you get any news about it other than the comments in the feature request ?Complemental
@JoseF: No, sorry.Gwyn
I see that it was upgraded from Priorty 3 to Priority 2 on Nov. 28, 2017Purview
G
15

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.

Gwyn answered 2/7, 2017 at 12:50 Comment(0)
I
6

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

Irredentist answered 24/8, 2018 at 0:14 Comment(0)
M
1

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

Mickens answered 15/12, 2018 at 21:11 Comment(0)
F
0

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

Fop answered 1/8, 2018 at 10:56 Comment(0)
T
0

Now it is possible with the Room database 2.1.0.

You can make this possible by annotating the abstract class methods with @PrimaryKey, @ColumnInfo, @Embedded, and @Relation. The abstract class has to be annotated with @Autovalue.

Tailor answered 25/4, 2021 at 16:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.