Room database build errors for @Ignore annotation
See original GitHub issueHi,
I’m trying to use Room database within a Kotlin project, but I’m having issues with @Ignore
annotation.
I have a data class and I’d like to ignore one field. If I add @Ignore
to that field, when I build the project I get several errors saying: “Cannot find setter for field” and one: “Entities and Pojos must have a usable public constructor. You can have an empty constructor or a constructor whose parameters match the fields (by name and type).”
I’ve tried to add a new property within User class from GithubBrowserSample and when I build the project I get the same errors.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:6
Top Results From Across the Web
Room @Ignore annotation generates compile time error
I have tried to move the fields inside the class but nothing is working. If I remove the @Ignore annotation from error it...
Read more >Defining data using Room entities - Android Developers
Room supports several types of annotations that make it easier for you to search for details in your database's tables.
Read more >Room doesn't ignore @Ignore annotated constructor ...
When I try @JvmOverloads I get the build error: Room cannot pick a constructor since multiple constructors are suitable. Try to annotate unwanted...
Read more >Configuring Entities - CommonsWare
Since the text property is private and has no setter, one could argue that Room might ignore it automatically. Room, instead, generates a...
Read more >Error in generated Game.java (page 136) - PragProg Customers
java:7: warning: There are multiple good constructors and Room will pick the no-arg constructor. You can use the @Ignore annotation to eliminate ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You should move the
@Ignore
field outside of the constructor, like this:Right, but doesn’t that cause the data class to become mutable? Wouldn’t it need to be
var testme: String?
?I wanted to retain immutability, so I came up with the following solution:
This allows Room to have only a constructor that matches the fields of the entity.