Marco Zühlke ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=61f9220... ) *updated* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMGNkMWM2ZDVl... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16369?atlOrigin=eyJpIjoiMGNkMW... ) HHH-16369 ( https://hibernate.atlassian.net/browse/HHH-16369?atlOrigin=eyJpIjoiMGNkMW... ) PostGIS function st_extent(geometry) does not work ( https://hibernate.atlassian.net/browse/HHH-16369?atlOrigin=eyJpIjoiMGNkMW... )
Change By: Marco Zühlke ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=61f9220... )
I'm troubleshooting with an issue when using PostGIS function _st_extent(geometry)_.
Entity/Repository:
{code:java}@Entity
@Table(name = "geometry_entity")
@Data
public class GeometryEntity {
@Id
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "org.hibernate.id.UUIDGenerator")
private UUID id;
@Column(name = "the_geom")
private Polygon geometry;
}
public interface GeometryEntityRepository extends JpaRepository<GeometryEntity, UUID> {
@Query(value = "select extent(geometry) from GeometryEntity")
Optional<Polygon> getExtentByJPQL();
@Query(value = "select st_extent(geometry) from GeometryEntity")
Optional<Polygon> getExtentByST_PrefixedFunctionName();
@Query(value = "select st_extent(the_geom) from geometry_entity", nativeQuery = true)
Optional<Polygon> getExtentByNativeQuery();
}{code}
According to the doc [https://docs.jboss.org/hibernate/orm/6.1/userguide/html_single/Hibernate_... _extent_ AND _st_extent_ should work.
I have three different queries, two of them are using JPQL, the other one is written native.
None of them work, all results in an error.
The attempt to call {{getExtentByJPQL}}() results in:
{noformat}2023-03-24T17:19:37.115+01:00 ERROR 456308 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : ERROR: function extent(geometry) does not exist
Hinweis: No function matches the given name and argument types. You might need to add explicit type casts.
Position: 8
org.springframework.dao.InvalidDataAccessResourceUsageException: JDBC exception executing SQL [select extent(g1_0.the_geom) from field g1_0]; SQL [n/a]{noformat}
The attempt to call {{getExtentByST_PrefixedFunctionName}}() and {{getExtentByNativeQuery()}}results in:
{noformat}org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter$TupleBackedMap] to type [org.locationtech.jts.geom.Polygon]
at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:322){noformat}
Just as a side note, using _st_envelope_ / _envelope_ instead of _st_extent_ / _extent_ works on JPQL queries, using a native query ends up with same {{ConverterNotFoundException}} I get by using _st_extent_.
* spring-boot:3.0.4
* hibernate-spatial:6.1.7
* postgres/postgis:15-3.3 (also tested with other / older versions but it doesn’t make any difference)
Test case to reproduce the error:
[https://github.com/marcozet/spring-boot-3-hibernate-spatial|https://githu...]
( https://hibernate.atlassian.net/browse/HHH-16369#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16369#add-comment?atlOrigin=ey... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100219- sha1:ac3e918 )