【问题标题】:Error while trying to save a point to Postgres DB using Postgis尝试使用 Postgis 将点保存到 Postgres DB 时出错
【发布时间】:2017-03-17 03:19:25
【问题描述】:

我的实体类

@Type(type = "org.hibernate.spatial.GeometryType")
private Point location;

我的spring boot配置

spring.jpa.database=POSTGRESQL
spring.datasource.platform=postgres
spring.jpa.show-sql=true
#spring.jpa.hibernate.ddl-auto=validate
spring.datasource.driverClassName=org.postgresql.Driver
spring.datasource.url=****
spring.datasource.username=***
spring.datasource.password=**
spring.jpa.database-platform=org.hibernate.spatial.dialect.postgis.PostgisDialect

我在尝试保存时收到以下错误。

错误:列“位置”的类型是点,但表达式的类型是字节茶提示:您需要重写或强制转换表达式。位置:154

【问题讨论】:

    标签: hibernate spring-boot postgis


    【解决方案1】:

    似乎您正在尝试将 postgis geometry(point) data type 存储到数据类型为 postgresql point 的字段中。他们不一样

    【讨论】:

    • 谢谢,那么如何使用 spring JPA 在我的实体 pojo 中表示 postgis 点类型。
    • 也许可以换一种方式尝试——将数据库中列的数据类型更改为几何体
    猜你喜欢
    • 2020-09-01
    • 2021-01-03
    • 1970-01-01
    • 1970-01-01
    • 2019-01-14
    • 2015-04-13
    • 2021-01-13
    • 2021-01-10
    • 1970-01-01
    相关资源
    最近更新 更多