从 Hibernate Spatial 5.4.3 升级到 5.6.9 后列类型错误

Wrong column type after upgrading from Hibernate Spatial 5.4.3 to 5.6.9

我们正在尝试将 Hibernate 和 Hibernate Spatial 从版本 5.4 升级到 5.6(我们正在使用 MySQL 5.6)但是当启动我们的 Spring 启动应用程序时(运行ning spring boot 2.7.0) 我们运行 进入以下异常:

Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: wrong column type encountered in column [my_polygon] in table [my_table]; found [geometry (Types#BINARY)], but expecting [polygon (Types#ARRAY)]
  at org.hibernate.tool.schema.internal.AbstractSchemaValidator.validateColumnType(AbstractSchemaValidator.java:167)
  at org.hibernate.tool.schema.internal.AbstractSchemaValidator.validateTable(AbstractSchemaValidator.java:151)
  at org.hibernate.tool.schema.internal.GroupedSchemaValidatorImpl.validateTables(GroupedSchemaValidatorImpl.java:42)
  at org.hibernate.tool.schema.internal.AbstractSchemaValidator.performValidation(AbstractSchemaValidator.java:97)
  at org.hibernate.tool.schema.internal.AbstractSchemaValidator.doValidation(AbstractSchemaValidator.java:76)
  at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:204)
  at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:85)
  at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:335)
  at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:471)
  at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1498)
  at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:141)
  at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365)
  at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409)
  ... 195 common frames omitted

MyTable 的定义如下:

@Entity
public class MyTable {
  
    @Type(type = "jts_geometry")
    @Column(name = "my_polygon", columnDefinition = "polygon")
    public Polygon myPolygon;

    // Other properties
}

我试过完全删除 @Type 注释,但我仍然遇到同样的错误。我怎样才能使这项工作?

我实际上是通过将 columnDefinitionpolygon 更改为 geometry 来让它工作的:

@Entity
public class MyTable {
  
    @Type(type = "jts_geometry")
    @Column(name = "my_polygon", columnDefinition = "geometry")
    public Polygon myPolygon;

    // Other properties
}