在 PostGis 上的 Spring 引导空间查询中遇到无效的字节序标志值
Invalid endian flag value encountered on Spring Boot Spatial Query on PostGis
我正在尝试查询由一个点定义的圆形区域中的所有 property
。
我在 Spring Boot 中使用 Following 函数实现了一个基本的 CRUDRepository,我希望使用它从一个点通过一个区域搜索属性。
@Query(value = "SELECT * FROM property p WHERE ST_DWithin(geography(p.location), geography(:center), :radius)", nativeQuery = true)
List<Property> searchPropertyByArea(@Param("center") Point center,
@Param("radius") Integer radius);
但我不断收到:错误:遇到无效的字节序标志值。
实体对象:
public class Property {
@Id
@GeneratedValue(generator = "UUID")
@GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator")
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false, unique = true)
private UUID id;
@Column(name = "location", nullable = true, columnDefinition = "geometry(POINT,4326)")
@JsonSerialize(using = PointSerializer.class)
@JsonDeserialize(using = PointDeserializer.class)
private Point location;
}
我使用的库是:
<dependency>
<groupId>net.postgis</groupId>
<artifactId>postgis-jdbc</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.4.4.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-spatial</artifactId>
<version>5.4.27.Final</version>
</dependency>
和我的 application.properties
spring.jpa.database-platform=org.hibernate.spatial.dialect.postgis.PostgisPG95Dialect
该错误消息表示以 WKB 或 EWKB 格式给出的几何图形的第一个字节既不是 0(大端)也不是 1(小端):
SELECT geometry('0101000000000000000000F03F0000000000000040');
geometry
--------------------------------------------
0101000000000000000000F03F0000000000000040
(1 row)
SELECT geometry('0401000000000000000000F03F0000000000000040');
ERROR: Invalid endian flag value encountered.
LINE 1: SELECT geometry('0401000000000000000000F03F0000000000000040'...
^
所以 p.location
或 :center
以数字开头,而不是 00
或 01
。
我正在尝试查询由一个点定义的圆形区域中的所有 property
。
我在 Spring Boot 中使用 Following 函数实现了一个基本的 CRUDRepository,我希望使用它从一个点通过一个区域搜索属性。
@Query(value = "SELECT * FROM property p WHERE ST_DWithin(geography(p.location), geography(:center), :radius)", nativeQuery = true)
List<Property> searchPropertyByArea(@Param("center") Point center,
@Param("radius") Integer radius);
但我不断收到:错误:遇到无效的字节序标志值。
实体对象:
public class Property {
@Id
@GeneratedValue(generator = "UUID")
@GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator")
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false, unique = true)
private UUID id;
@Column(name = "location", nullable = true, columnDefinition = "geometry(POINT,4326)")
@JsonSerialize(using = PointSerializer.class)
@JsonDeserialize(using = PointDeserializer.class)
private Point location;
}
我使用的库是:
<dependency>
<groupId>net.postgis</groupId>
<artifactId>postgis-jdbc</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.4.4.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-spatial</artifactId>
<version>5.4.27.Final</version>
</dependency>
和我的 application.properties
spring.jpa.database-platform=org.hibernate.spatial.dialect.postgis.PostgisPG95Dialect
该错误消息表示以 WKB 或 EWKB 格式给出的几何图形的第一个字节既不是 0(大端)也不是 1(小端):
SELECT geometry('0101000000000000000000F03F0000000000000040');
geometry
--------------------------------------------
0101000000000000000000F03F0000000000000040
(1 row)
SELECT geometry('0401000000000000000000F03F0000000000000040');
ERROR: Invalid endian flag value encountered.
LINE 1: SELECT geometry('0401000000000000000000F03F0000000000000040'...
^
所以 p.location
或 :center
以数字开头,而不是 00
或 01
。