2016-11-08 4 views
0

ためCommandeでのclientIdを見つけることができません私の最初のクラスです。は@ToOne関係ここ

@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; 
} 

私の第二1:

@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; 
} 

i "はプロジェクトを作る" 私はこのエラーを持っていますメッセージ:

Error:Execution failed for task ':app:greendao'. Can't find clientId in Commande for @ToOne relation

私のクラス間の関係に問題がありますが、解決方法はわかりません。 GreenDAOの文書では、関係について明示的に十分ではありません。

答えて

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; 
} 
関連する問題