I use @query to Insert XY to Geometry in Postgres. But it error.
@Modifying
@Query(value = " insert into mypoints (name,geom) values (:name,SRID=4326;POINT(:x :y))", nativeQuery = true)
@Transactional
void addSPCTY(@Param("name") String ten,@Param("x") String x,@Param("y") String y);
Error in Java: org.postgresql.util.PSQLException: ERROR: syntax error near;
Hot to sert SRID in spring boot? Please hep me. Tks all
I could insert record using following changes:
@Query(value = "insert into geometries (name,geom) values (:name, ST_SetSRID(ST_MakePoint(:x, :y), 4326))", nativeQuery = true)
values for x and y has to be passed as float - if used String then it throws error. I hope it will help to resolve the issue.
Reference Doc: https://postgis.net/docs/ST_MakePoint.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.