0

我有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 插入新数据时,我需要将一些多边形连接到一个区域,然后加入的列留空。如何解决?

4

1 回答 1

0

需要insertable = false, updatable = false在 JPA 属性中删除

于 2019-12-13T08:29:57.653 回答