我如何使用本机查询更新具有Postgis扩展名的Postgresql中的点类型数据

时间:2019-07-04 08:32:39

标签: postgresql jpa postgis spring-repositories

我在具有postgis扩展的postgresql中插入了点类型数据。

我已经尝试过该查询,给出了错误

@修改 @交易 @Query(value =“ UPDATE lat_lang SET geom = ST_transform(ST_SetSRID(ST_MakePoint(:lat,:lang),4326),3857),latitude =:lat,longitude =:lang WHERE uid = 1;”,nativeQuery = true)

int updateGeom(@Param(“ lat”)Double lat,@Param(“ lang”)Double lang);

这是我遇到的错误

org.postgresql.util.PSQLException:错误:函数st_makepoint(bytea,bytea)不存在   提示:没有函数匹配给定的名称和参数类型。您可能需要添加显式类型转换。   位置:50     在org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2440)〜[postgresql-42.2.5.jar:42.2.5]     在org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2183)〜[postgresql-42.2.5.jar:42.2.5]     在org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:308)〜[postgresql-42.2.5.jar:42.2.5]     在org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441)〜[postgresql-42.2.5.jar:42.2.5]     在org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)〜[postgresql-42.2.5.jar:42.2.5]     在org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:143)〜[postgresql-42.2.5.jar:42.2.5]     在org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:120)〜[postgresql-42.2.5.jar:42.2.5]     在com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61)〜[HikariCP-3.2.0.jar:na]     在com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java)〜[HikariCP-3.2.0.jar:na]     在org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:175)〜[hibernate-core-5.3.10.Final.jar:5.3.10.Final]     在org.hibernate.engine.query.spi.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:107)〜[hibernate-core-5.3.10.Final.jar:5.3.10.Final]     在org.hibernate.internal.SessionImpl.executeNativeUpdate(SessionImpl.java:1593)〜[hibernate-core-5.3.10.Final.jar:5.3.10.Final]

@修改 @交易 @Query(value =“ UPDATE lat_lang SET geom = ST_transform(ST_SetSRID(ST_MakePoint(:lat,:lang),4326),3857),latitude =:lat,longitude =:lang WHERE uid = 1;”,nativeQuery = true)

int updateGeom(@Param(“ lat”)Double lat,@Param(“ lang”)Double lang);

0 个答案:

没有答案