我是Hibernate的新手,我遇到了这么大的问题。我有两个类:客户端和预订。客户是与预订的一对多关系
Client.java
@Entity
@Table (name="Clients")
public class Clients {
@Id
@GeneratedValue
@Column(name="id_client")
private int id_client;
public Clients()
{}
@OneToMany(mappedBy = "client")
private Set<Reservations> reservation;
@Column(name="name")
private String name;
@Column(name="last_name")
private String lastName;
@Column(name="phoneNo")
private String phoneNo;
public Clients(String name, String lastName, String phone)
{
this.name =name;
this.lastName = lastName;
this.phoneNo = phone;
}
// setters , getters
Reservations.java
@Entity
@Table (name="Reservations")
public class Reservations {
@Id
@GeneratedValue
@Column(name="id")
private int id_res;
@ManyToOne
@JoinColumn( name = "id_client" )
private Clients client;
@Column(name="date_start")
private Calendar dateStart;
@Column(name="date_end")
private Calendar dateEnd;
@Column(name="price")
private BigDecimal price;
public Reservations() {}
public Reservations(Clients client, Calendar dateStart, Calendar dateEnds)
{
this.client = client;
this.dateStart = dateStart;
this.dateEnds = dateEnds;
}
// setters , getters
我的问题是:我收到错误
无法创建sessionFactory object.org.hibernate.AnnotationException:使用@OneToMany或@ManyToMany定位未映射的类:model.java.hibernateApp.Clients.reservation [model.java.hibernateApp.Reservations]
但是,尽管我看到很多类似的主题,我无法解决这个问题,谢谢你的帮助。 我从以下方面学到了:http://viralpatel.net/blogs/hibernate-one-to-many-annotation-tutorial/