【问题标题】:org.postgresql.util.PSQLException: ERROR: column "geo_detail" is of type point but expression is of type bytea any solution please?org.postgresql.util.PSQLException: ERROR: column "geo_detail" is of type point but expression is of type bytea 请问有什么解决方案吗?
【发布时间】:2019-11-19 00:56:08
【问题描述】:

实体

@Column(columnDefinition = "Point") 
private Point geoDetail

服务

order.setGeoDetail(new GeometryFactory().createPoint(new Coordinate(Double value,double value)));

应用程序属性

@dialect spring.jpa.hibernate.dialect=org.hibernate.spatial.dialect.postgis.PostgisDialect

org.postgresql.util.PSQLException:错误:列“geo_detail”属于 键入点,但表达式的类型为 bytea 提示:您需要 重写或转换表达式。

数据库 - geo_detail -datatype->点

【问题讨论】:

    标签: java postgresql hibernate spring-boot


    【解决方案1】:

    我认为这笔交易是您的geo_detail 列包含geoDetailid,并且您在接收Long 时尝试获取Object。 使用@JoinColumn(name = "geo_detail")

    【讨论】:

    • 嗨罗马,谢谢你的时间,我想你误解了当我将点的值设置为例如:POINT(77.6879585 12.9377677) 我收到错误 -column "geo_detail" 的类型为 point 但表达式的类型为 bytea 提示:您需要重写或强制转换表达式。
    • 你能把你的实体(点和带有“geoDetail”字段的实体)的代码和这个实体的模式都放在这里吗?
    • 实体 public class Orders { Id GeneratedValue(strategy=GenerationType.IDENTITY) private Long orderId; Column(columnDefinition = "Point") 私有点 geoDetail; public Point getGeoDetail() { return geoDetail; } public void setGeoDetail(Point geoDetail) { this.geoDetail = geoDetail; } }
    • ========================= 这就是我从双纬度顺序计算点的方式.setGeoDetail((Point )new GeometryFactory().createPoint(new Coordinate(ordersModel.getGetLat() , ordersModel.getGetLot())));//POINT (77.6879585 12.9377677) ====== spring.jpa.hibernate.dialect =org.hibernate .spatial.dialect.postgis.PostgisDialect
    • 我的要求是以双数据类型的形式从 UI 获取的点的形式存储 geoLocation。
    猜你喜欢
    • 2018-11-16
    • 2022-12-27
    • 2022-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-30
    • 1970-01-01
    • 2022-11-18
    相关资源
    最近更新 更多