I tried @OneToOne Mapping with non @Entity class but it seems i am doing something wrong please help. Here is error log for the following classes.
Caused by: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on com.package.model.Hotel.address references an unknown entity: com.package.model.Address
Here is my 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
Here is my 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;
Address class is not @Entity class Only Hotel class have @Entity. Now i am trying to insert/create(table) data with the value of Address.java using spring and JPA into a single hotel table, And i am getting above complain in my Eclipse console.
Here is my RestController from where i am trying to get data
@Autowired
private RoomRepository roomRepository;
//RoomRepository is Interface which is extending JpaRepository
@GetMapping("hotels")
public List<Room> retriveAllHotels(){
return roomRepository.findAll();
}
Just do:
and the Address fields will be a part of a Hotel entity