hibernate - 为什么我有 org.postgresql.util.PSQLException:错误:遇到无效的字节序标志值?
问题描述
我最近使用 hibernate-spatial 5 并且遇到了问题。当我尝试将几何数据添加到 Postgres 时。我在提交事务阶段遇到了下一个错误:
javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not execute statement] with root cause
org.postgresql.util.PSQLException: ERROR: Invalid endian flag value encountered.
我的实体看起来像这样,我已经像以前的帖子一样配置了它,但有同样的问题:
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "geotable")
@Indexed(index = "geoindex")
public class GeoPointModel implements Serializable {
@Id
@GeneratedValue
@DocumentId
@Column(name = "point_id")
private Long id;
@Field(index = Index.YES, analyze = Analyze.NO, store = Store.YES)
@FieldBridge(impl = GeoBridge.class)
@Column(name = "location", columnDefinition = "geometry(Point,4326)")
private Geometry location;
}
我的依赖:
dependencies {
implementation 'org.hibernate:hibernate-core:5.4.5.Final'
implementation 'org.hibernate:hibernate-spatial:5.4.5.Final'
implementation 'org.springframework:spring-orm:5.1.5.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-jdbc', version: '2.1.8.RELEASE'
compile group: 'org.hibernate', name: 'hibernate-search-orm', version: '5.11.3.Final'
compile group: 'org.apache.lucene', name: 'lucene-spatial', version: '5.5.5'
compile group: 'com.spatial4j', name: 'spatial4j', version: '0.4.1'
compile group: 'com.vividsolutions', name: 'jts', version: '1.13'
compile group: 'net.postgis', name: 'postgis-jdbc', version: '2.3.0'
}
方言:
dialect=org.hibernate.spatial.dialect.postgis.PostgisPG9Dialect
我失去了什么?如何修复?
解决方案
可能是https://hibernate.atlassian.net/browse/HHH-11086?一种解决方法似乎是使用点而不是几何:https ://forum.hibernate.org/viewtopic.php?p=2490324&sid=36d7ee961e6ff5e45e71a8aa613cb469#p2490324
在不那么相关的说明中,如果您仍在尝试使用 Hibernate Search(毕竟您在这个问题中标记了它),请查看@Spatial
:https ://docs.jboss.org/hibernate/search/ 5.11/reference/en-US/html_single/#spatial-indexing。在你的情况下,你只需要让你的GeoPointModel
类实现org.hibernate.search.spatial.Coordinates
并@Spatial(name = "location")
在GeoPointModel
.
推荐阅读
- copy - 在 PowerBI Embedded 中,通过自定义菜单命令配置时不会出现“复制”命令
- rust - Zola:从 toml 标头访问额外数据
- sql - 没有唯一分区时的 SQL WINDOW FUNC
- python - 导入其他 Python 文件 - 调用路径
- laravel-7 - 我怎样才能得到另一个班级的ID?
- dart - Dart:嵌套在地图中的地图
- javascript - Mongoose 对自定义字符串 _id 的引用
- reactjs - 更新未在反应前端显示的已更改项目的状态
- python - 涵盖所有案例的最少项目数
- python - Aiohttp异步获取代理请求不起作用