我要更新行:
@PutMapping(value = "/updateEdits")
@Transactional
public void updateGeometry(@RequestBody List<Geometry> values){
geometryRepository.saveAll(values);
}
但它不起作用。
警告12400 --- [nio-8080-exec-8]运行时实体。抽象实体持久性:HHH 000502:[com.samm.fiberplanner.entity.Geometry]实体的[feature]属性已修改,但由于该属性不可变,因此不会更新。
已发布的实体:
@Getter
@Setter
@ToString
@RequiredArgsConstructor
@Entity
public class Geometry {
@Id
private Long gId;
private String type;
@Column(columnDefinition = "TEXT")
private String coordinates;
@OneToOne
@MapsId
private Feature feature;
}
@Getter
@Setter
@ToString
@RequiredArgsConstructor
@Entity
public class Feature {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long fId;
private String type;
@ToString.Exclude
@OneToOne(mappedBy = "feature",cascade = CascadeType.ALL)
private Properties properties;
@ToString.Exclude
@OneToOne(mappedBy = "feature",cascade = CascadeType.ALL)
private Geometry geometry;
@ToString.Exclude
@ManyToOne
@JoinColumn(name = "geo_json_id")
private GeoJson geoJson;
}
为什么[feature]属性是不可变的?我如何更新表?
2条答案
按热度按时间lskq00tm1#
试试这个,如果有用的话
x6h2sr282#
将cascade=CascadeType.ALL添加到此关系中的实体关系@OneToOne @MapsId私有要素功能;,它将使实体可变。