我在我的春季專案中使用 Hibernate。但它不適用于一對一的關系。它給了我以下錯誤。
Unable to build Hibernate SessionFactory; nested exception is org.hibernate.MappingException: Could not determine type for: com.example.TransfertNational.model.Client, at table: ComptePaiement, for columns: [org.hibernate.mapping.Column(client)]
我在互聯網上進行了一些搜索,但它對我不起作用。
客戶物體:
@Data @Entity
@AllArgsConstructor @NoArgsConstructor @ToString
public class Client {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
private String typeTransfert;
private String typePiece;
private String cin;
private String sexe;
private String prenom;
private String typePieceIdentite;
private String paysEmission;
private String numPI;
private String validitePI;
private String dateNaissance;
private String profession;
private String nationalite;
private String paysAdresse;
private String adresseLegale;
private String ville;
private String gsm;
private String email;
@OneToMany(fetch = FetchType.LAZY,
cascade = CascadeType.ALL)
private Set<Beneficiaire> beneficiares;
@OneToOne(fetch = FetchType.LAZY,
cascade = CascadeType.ALL)
private ComptePaiement comptePaiement;
}
ComptePaiement 物體:
@Data
@Entity
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class ComptePaiement {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
private String solde;
private String rip;
private Client client;
}
uj5u.com熱心網友回復:
評論回復:
你可能丟失@JoinColumn的Client或ComptePaiement與mappedBy在@OneToOne注解,這取決于其將持有參考ID資料庫。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/409302.html
標籤:
下一篇:如何洗掉物體
