sách gpt4 ai đã đi

Đối tượng tham chiếu đến một phiên bản tạm thời chưa lưu - lưu phiên bản tạm thời trước khi xóa bằng chế độ ngủ đông

In lại 作者:行者123 更新时间:2023-12-02 03:38:22 28 4
mua khóa gpt4 Nike

我正在尝试执行此查询:

StringBuffer sb = new StringBuffer();
sb.append("select p from PointsEntity p " + "where within(p.coordinates,:polygon) = true");

但我有一个异常(exception):

org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.gisapp.springboot.backend.apirest.models.entity.PolygonEntity

这是 PolygonEntity:

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(name = "user_id")
private Long userId;

@Column(name = "user_email")
private String userEmail;

@Column(name = "point_name")
private String pointName;

@Column(name = "coordinates")
private Polygon coordinates;

我已经阅读了一个可能的解决方案đây但观察实体,该解决方案已在包含多边形集合的 UserEntity 中实现:

@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinColumn(name = "user_id")
private List pointsList;

@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinColumn(name = "user_id")
private List polygonsList;

为什么我会遇到这个异常?

1 Câu trả lời

最后我用了另一种方式来使用within方法。

我创建了一个时态表和一个实体来保存多边形,稍后我执行此查询:

StringBuffer sb = new StringBuffer();
sb.append("select p from PointsEntity p, TempPolygonEntity t "
+ "where within(p.coordinates, t.coordinates) = true");

多边形会被保存,并在使用后被删除。

关于java - 对象引用未保存的 transient 实例 - 在使用 hibernate 空间刷新之前保存 transient 实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56849006/

28 4 0
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com