[英]How to Insert X Y and SRID 4326 to Geometry in Spring Boot and Postgres?
I use @query to Insert XY to Geometry in Postgres.我使用@query 在 Postgres 中将 XY 插入几何。 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;
Java 中的错误: org.postgresql.util.PSQLException: ERROR: syntax error near;
Hot to sert SRID in spring boot?在 spring 引导中热插入 SRID? 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) @Query(value = "插入几何 (name,geom) 值 (: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. x 和 y 的值必须作为浮点数传递- 如果使用字符串,则会引发错误。 I hope it will help to resolve the issue.我希望它有助于解决问题。
Reference Doc: https://postgis.net/docs/ST_MakePoint.html参考文档: https://postgis.net/docs/ST_MakePoint.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.