'Cannot update entity with JPA because the @onetoone dependent property is immutable but there is no @immutable annotation

I want to update rows:

 @PutMapping(value = "/updateEdits")
    @Transactional
    public void updateGeometry(@RequestBody List<Geometry> values){

        geometryRepository.saveAll(values);
    }

But it does not work.

WARN 12400 --- [nio-8080-exec-8] o.h.p.entity.AbstractEntityPersister : HHH000502: The [feature] property of the [com.samm.fiberplanner.entity.Geometry] entity was modified, but it won't be updated because the property is immutable.

Releated entities:

@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;
}

Why is [feature] property is immutable? How can i update the table?



Solution 1:[1]

Try this if it works

@Entity(mutable = "true")

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 S Banerjee