1

I have a Lombok-annotated POJO that I'm using for other parts of the app and is not intended for Room. But when I try to build my project I get the Entity class must be annotated with @Entity error about it and the build fails.

I know I could just force one of my actual Room entities to fill this data object's role by adding a bunch of @Ignored fields, but that seems dumb. How can I tell it that this class is not an entity and that Room should leave it alone?

This is the class it complains about:

import androidx.annotation.DrawableRes;

import lombok.Builder;
import lombok.Value;

@Value
@Builder
public class MyPOJO {
    final String matchQuality;
    final String identifier;
    final String fitDate;
    @DrawableRes
    final int image;
}
1
  • Note: This happens even if I remove the Lombok annotations and include manual implementations of the constructor, getters/setters, etc Commented Feb 26, 2020 at 18:23

1 Answer 1

1

This was my bad.

When I was just starting with my implementation and hadn't made any entities, I needed something to go in the Database entities annotation and put MyPOJO there as a placeholder:

@Database(entities = {MyPOJO.class}, version = 1)
abstract public class MyDB extends RoomDatabase {

Once I replaced this with my actual @Entity classes, I no longer get this build error.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.