我试图@OneToOne映射与非@Entity类,但是它好像我做错了什么,请帮助。 下面是错误日志以下类。
org.hibernate.AnnotationException:由造成了com.package.model.Hotel.address @OneToOne或@ManyToOne引用了未知的实体:com.package.model.Address
这里是我的Address.java
private String street;
private String city;
private String state;
private int pincode;
private String country;
private String locationCoordinates;
//Getters and setters removed from the code
这里是我的Hotel.java
@Id
@GeneratedValue
private int id;
private String password;
private String name;
private String contactPerson;
private String email;
private String countryCode;
private long phone1;
private long phone2;
@OneToOne(cascade=CascadeType.ALL)
private Address address;
private String description;
地址类不是@Entity类唯一的酒店类有@Entity。 我现在想插入/创建(表),但以春季和JPA成一个单一的酒店表Address.java的数值数据,我得到上面抱怨我的Eclipse控制台。
下面是我在哪里试图让我的数据RestController
@Autowired
private RoomRepository roomRepository;
//RoomRepository is Interface which is extending JpaRepository
@GetMapping("hotels")
public List<Room> retriveAllHotels(){
return roomRepository.findAll();
}