我要更新行:
@PutMapping(value = "/updateEdits")
@Transactional
public void updateGeometry(@RequestBody List<Geometry> values){
geometryRepository.saveAll(values);
}
但它不工作。
WARN 12400—[nio-8080- exc -8] . h.p.p entity. abstractentitypersister: HHH000502: [com.sam .fiberplanner.entity.]的[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]属性是不可变的?我如何更新表?
如果可以的话试试
@Entity(mutable = "true")
在此关系中将cascade=CascadeType.ALL
添加到您的实体关系
@OneToOne
@MapsId
private Feature feature;
,它将使实体可变