我正在尝试为会议室预订构建一个小型演示。
我的实体是城市->位置->楼层->从上到下具有一对多关系的房间。
这些是我的实体
3
The asdfj
2
asldkja sfaslkj asdfljk
3
asdfjk asdfjlkasdf alksjdf asdflkj
4
但是现在当我尝试构建时,我遇到了错误
@Entity
@Table(name="office_city")
public class City {
@Id
@GeneratedValue
private int cityId;
private String cityName;
@OneToMany(fetch = FetchType.EAGER,mappedBy="city", cascade = CascadeType.ALL)
@JsonManagedReference
private List<Location> location;
public List<Location> getLocation() {
return location;
}
public void setLocation(List<Location> location) {
this.location = location;
}
public int getCityId() {
return cityId;
}
public void setCityId(int cityId) {
this.cityId = cityId;
}
public String getCityName() {
return cityName;
}
public void setCityName(String cityName) {
this.cityName = cityName;
}
@Override
public String toString() {
return "[cityId="+cityId+" cityName="+cityName+" location="+location.size()+"]";
}
}
public class Location {
@Id
@GeneratedValue
private int locationId;
private String locationName;
@ManyToOne
@JoinColumn(name="cityId")
@JsonBackReference
private City city;
@OneToMany(fetch = FetchType.EAGER,mappedBy="location",cascade=CascadeType.ALL)
@JsonManagedReference
private List<Floor> floor;
public List<Floor> getFloor() {
return floor;
}
public void setFloor(List<Floor> floor) {
this.floor = floor;
}
public City getCity() {
return city;
}
public void setCity(City city) {
this.city = city;
}
public int getLocationId() {
return locationId;
}
public void setLocationId(int cityId) {
this.locationId = cityId;
}
public String getLocationName() {
return locationName;
}
public void setLocationName(String cityName) {
this.locationName = cityName;
}
}
public class Floor {
@Id
@GeneratedValue
private int floorId;
private String floorName;
@ManyToOne
@JoinColumn(name="locationId")
@JsonBackReference
private Location location;
@OneToMany(fetch = FetchType.EAGER,mappedBy="floor",cascade=CascadeType.ALL)
@JsonManagedReference
private List<Room> room;
public List<Room> getRoom() {
return room;
}
public void setRoom(List<Room> room) {
this.room = room;
}
public Location getLocation() {
return location;
}
public void setLocation(Location location) {
this.location = location;
}
public int getFloorId() {
return floorId;
}
public void setFloorId(int cityId) {
this.floorId = cityId;
}
public String getFloorName() {
return floorName;
}
public void setFloorName(String cityName) {
this.floorName = cityName;
}
}