一对多关系的会议室数据库

时间:2018-08-05 19:21:48

标签: database one-to-many android-room pojo

我有2个实体:员工和专业。 每个员工可以拥有一些专业。 POJO已生成。

@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...

和专业

@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...

我有此错误: 错误:实体和Pojos必须具有可用的公共构造函数。您可以有一个空的构造函数或一个其参数与字段匹配的构造函数(按名称和类型)。

我检查了很多问题并阅读了文档,但这对我没有帮助。谢谢

1 个答案:

答案 0 :(得分:2)

您应该将@Ignore添加到serialVersionUID字段。 鉴于Room,这只是另一列。

g++ -std=c++17 -O0 -Wall -pedantic main.cpp
相关问题