我正在努力開發一個管理關閉書籍(庫)的應用程序。 我使用hibernate ti生成關係數據庫。 我有這些類:用戶,貼壁,管理員如何使休眠處於休眠狀態
@entity
@Table(name="users")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="TYPE_USER",discriminatorType=DiscriminatorTyp)
class User{
@Id
private int UserId;
private String name;
private String email
}
@Entity
@DiscriminatorValue("ADH")
public class Adherent extends User{
private int solde;
private int penalised;
@OneToMany(mappedBy="adherent")
private List<Ouvrage> ouvrages;
}
@Entity
@Table(name="ouvrages")
public class Ouvrage {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private int idOuvrage;
private String ISBN;
private String Titre;
private boolean reservable;
private boolean dispo;
@ManyToOne
@JoinColumn(name="proprietaire")
private Adherent proprietaire;
@OneToOne(mappedBy="ouvrage")
private Emprunt emrunt;
}
@Entity
@DiscriminatorValue("ADM")
public class Admin extends User{
private String notifications;
private String messages;
}
,當我的測試,我得到這個錯誤
上dao.entities.Emprunt.adherent @OneToOne或@ManyToOne引用了未知的實體: dao.entities.Adherent
讓你有一些外地Emprunt.adherent,你不要打擾張貼的類。 WTF? –