I have 2 Entities: Employee and Specialty. Every Employee can have some Specialties. POJOs are generated.
@Entity(indices = {@Index(value = {"f_name", "l_name", "birthday",
"avatarLink"}, unique = false)}, inheritSuperIndices = true)
public class Employee implements Serializable {
@PrimaryKey(autoGenerate = true)
private int employeeId;
private String f_name;
private String l_name;
private String birthday;
@Ignore
private int age;
private String avatarLink;
@Embedded
private List<Specialty> specialty;
private final static long serialVersionUID = -8824149947485321362L;
@Ignore
public Employee() {
}
public Employee(int employeeId, String f_name, String l_name, String
birthday, String avatarLink, List<Specialty> specialty) {
this.employeeId = employeeId;
this.f_name = f_name;
this.l_name = l_name;
this.birthday = birthday;
this.avatarLink = avatarLink;
this.specialty = specialty;
}
public int getEmployeeId() {
return employeeId;
}
public void setEmployeeId(int employeeId) {
this.employeeId = employeeId;
}
And some more setters\getters...
And Specialty
@Entity
public class Specialty implements Serializable {
@PrimaryKey
private int specId;
private String specName;
private final static long serialVersionUID = 4288061416169200241L;
public Specialty(int specId, String specName) {
this.specId = specId;
this.specName = specName;
}
@Ignore
public Specialty() {
}
public int getSpecId() {
return specId;
}
And some more setters\getters...
I have this error: error: 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 check so many questions and read docs, but it not helps me. Thank you
you should add @Ignore to serialVersionUID fields. In view of Room, it's just another column.
@Ignore
private final static long serialVersionUID = 4288061416169200241L;