3

The following simple test returns an error

CREATE TABLE track (
  position point NOT NULL
);
INSERT INTO track VALUES (
  position=ST_PointFromText('POINT(-45.62390335574153 -3.9551761173743847)')
);

Error:

ERROR 1416 (22003): Cannot get geometry object from data you send to the GEOMETRY field

What am I doing wrong?

1

2 Answers 2

6

Wrong syntax... Instead of

INSERT INTO track VALUES (
    position=ST_PointFromText(...)
);

use

INSERT INTO track SET
    position=ST_PointFromText(...);

Reference: https://dev.mysql.com/doc/refman/5.7/en/insert.html

3

I am using Spring Boot data JPA and MySQL.

Please add below properties in spring boot application.properties

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

I was successful to save Point column

Hibernate: select max(id) from shoplocation
Hibernate: insert into shoplocation (address, area, geo_location, id) values (?, ?, ?, ?)

I am using Spring Boot 1.5.9 and Hibernate 5.2 and MySQL 5.6

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.