这是我的第一堂课:
@Entity(
active = true,
nameInDb = "CLIENTS"
)
public class Client {
@Id(autoincrement = true)
private long id;
@NotNull
private String nom;
@NotNull
private String prenom;
@ToMany(referencedJoinProperty = "commandeId")
private List<Commande> listeCommandes;
}
我的第二个:
@Entity(
active = true,
nameInDb = "COMMANDES"
)
public class Commande {
@Id(autoincrement = true)
private long id;
@NotNull
private String libelle;
@NotNull
@ToOne(joinProperty = "clientId")
private Client client;
}
当我执行“制作项目”时,我收到以下错误消息:
错误:任务':app:greendao'的执行失败。 在Commande中找不到@ToOne关系的clientId
看来我的课程之间的关系有问题,但我不知道如何解决它。关于人际关系,GreenDAO文件没有明确说明
答案 0 :(得分:0)
好的就是答案。
第一堂课:
@Entity(
active = true,
nameInDb = "CLIENTS"
)
public class Client {
@Id(autoincrement = true)
private long id;
@NotNull
private String nom;
@NotNull
private String prenom;
@ToMany(referencedJoinProperty = "clientId")
private List<Commande> listeCommandes;
}
第二课:
@Entity(
active = true,
nameInDb = "COMMANDES"
)
public class Commande {
@Id(autoincrement = true)
private long id;
@NotNull
private String libelle;
@NotNull
private long clientId;
@NotNull
@ToOne(joinProperty = "clientId")
private Client client;
}