I\'m converting a project to Kotlin and I\'m trying to make my model (which is also my entity) a data class I intend to use Moshi to convert the JSON responses from the API<
As stated in Room Database Entity:
Each entity must either have a no-arg constructor or a constructor whose parameters match fields (based on type and name).
So adding an empty constructor and annotating your parameterized constructor with @Ignore will solve your problem. An example:
public class POJO {
long id;
String firstName;
@Ignore
String lastName;
public POJO() {
}
@Ignore
public POJO(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
// getters and setters
// ...
}