Why I can't map a Point field of my entity class on a Point field on the database? column “location” is of type point but expression is of type bytea

旧城冷巷雨未停 提交于 2019-12-04 15:51:38

You have everything setup correctly for Postgresql + Postgis, but your database uses the Postgresql geometric types, not the ones provided by Postgis. Hibernate Spatial only supports the Postgis spatial extension.

Make sure Postgis is installed, and your tables uses the Postgis provided type 'Geometry' for the location column.

I'm using Mysql 5 with Point object and had the same issue. The was with the newest dialect version, so I downgraded it. Changing the aplication.properties from this:

spring.jpa.properties.hibernate.dialect=org.hibernate.spatial.dialect.mysql.MySQL56InnoDBSpatialDialect
spring.jpa.database-platform = org.hibernate.spatial.dialect.mysql.MySQLSpatial56Dialect

To this:

spring.jpa.properties.hibernate.dialect=org.hibernate.spatial.dialect.mysql.MySQL5InnoDBSpatialDialect
spring.jpa.database-platform = org.hibernate.spatial.dialect.mysql.MySQLSpatial56Dialect

I hope it can help you.

I was using Hibernate-{core,spatial} v5.2.9 everything was as is above, except from how dialect was being set in application.properties. I NEEDED:

spring.jpa.database-platform=org.hibernate.spatial.dialect.postgis.PostgisDialect

Now it works. I don't need even any @Column annotation in my Entity.

Tinki

I would suggest using more generic approach, which is demonstrated in this answer. For me installing database extensions/ operating with geometrical types for such a simple type as Point is an overkill.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!