PostGis invalid geometry when using ST_GeomFromText

178 Views Asked by At

i am using postgis with spring boot hibernate jpa.

Code in Repository:

@Query(value = "select {h-schema}ref_plz_geom.plz from {h-schema}ref_plz_geom WHERE ST_Contains(geom, ST_Transform(ST_GeomFromText('POINT(:userLongitude :userLatitude)',4647),4326))", nativeQuery=true)

String getPlz(Double userLongitude, Double userLatitude);

i get the following error :

2023-01-10 14:44:08,479 ERROR org.hibernate.engine.jdbc.spi.SqlExceptionHelper - ERROR: parse error - invalid geometry
  Hint: "POINT(:u" <-- parse error at position 8 within geometry

When i run the same query in postgres i get the pincode:

select
        pincode 
    from
        pin_code_table
    WHERE
        ST_Contains(geom, ST_Transform(ST_GeomFromText('POINT(32528808.761501245 5471624.355)',4647),4326))

But when i run the sring boot application , i get the above error.Please advice.

1

There are 1 best solutions below

1
On

You need to declare the parameter name:

String getPlz(@Param("userLongitude") Double userLongitude, @Param("userLatitude") Double userLatitude);