我有2节课。第一的:
@Entity
@Table(name = "region", schema="building")
public class Region {
/**
* id
*/
@Id
@Column(name = "regionid")
@GeneratedValue(strategy= GenerationType.IDENTITY)
private Long id;
@OneToMany(cascade = CascadeType.ALL)
@JoinColumn(name = "regionid", referencedColumnName = "regionid", insertable = false, updatable = false)
private List<Polygon> polygonsList;
}
第二:
@Entity
@Table(name = "polygon", schema="building")
public class Polygon {
/**
* id
*/
@Id
@Column(name = "polygonid")
@GeneratedValue(strategy= GenerationType.IDENTITY)
private Long id;
}
当我使用 jparepository 插入新数据时,我需要将一些多边形连接到一个区域,然后加入的列留空。如何解决?