问题描述
我有下面的房间实体,它有很多disponibilities,当我添加一个带有disponibilities 列表的房间时,房间被保存,但列表没有。我在这段关系中缺少什么?
@Entity
public class RoomEntity {
@Id
private String classRoomId;
private String label;
@OnetoMany(mappedBy = "room",fetch = FetchType.LAZY,cascade = CascadeType.ALL)
private List<disponibilityEntity> disponibilities;
public void adddisponibilities(List<disponibilityEntity> disponibilityEntities) {
if (CollectionUtils.isEmpty(disponibilities)) {
disponibilities = new ArrayList<>();
}
disponibilities.addAll(disponibilityEntities);
disponibilityEntities.forEach(item -> item.setRoom(this));
}
}
@Entity
public class disponibilityEntity {
@Id
private String disponibilityId;
@JsonIgnore
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "fk_room")
private RoomEntity room;
}
roomEntity.adddisponibilities(classRoomEntity.getdisponibilities());
roomrepository.save(roomEntity);
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)