我使用的是Springboot2.1,orm使用的是hibernate最新版本。当我想把我的数据持久化到db时,我会遇到这个错误:
数据截断:无法从发送到几何字段的数据中获取几何对象
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
public class Province {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Long Id;
String name;
@Column(nullable = false, columnDefinition = "MultiPolygon")
MultiPolygon multiPolygon;
}我想问题出在我的方言上。
server:
port: 8080
logging:
level:
com.mousavi007.serverhavadan: debug
spring:
mail:
host: smtp.gmail.com
port: 587
username:********
password: ******
properties:
mail:
smtp:
auth: true
starttls:
enable: true
protocol: smtp
default-encoding: utf-8
datasource:
url: jdbc:mysql://localhost:3306/havadan
username: *************
password: *************
platform: mysql
jpa:
hibernate:
ddl-auto: update
database-platform: org.hibernate.dialect.MySQL8Dialect
database: mysql
show-sql: true什么是MySQL8和hibernate最新版本的空间困境?
发布于 2020-06-01 21:19:40
请使用
org.hibernate.spatial.dialect.mysql.MySQL8SpatialDialect
发布于 2020-07-31 17:36:39
您应该使用org.hibernate.spatial.dialect.mysql.MySQL8SpatialDialect并使用正确的几何体类型(在本例中为org.locationtech.jts.geom.MultiPolygon)。MultiPolygon字段上的@Column注释不是必需的。
更多信息请访问:https://docs.jboss.org/hibernate/orm/5.4/userguide/html_single/Hibernate_User_Guide.html#spatial
https://stackoverflow.com/questions/53713925
复制相似问题