Marco Zühlke (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=61f9220...
) *updated* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMGIxNDA1Yjg1...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16369?atlOrigin=eyJpIjoiMGIxND...
) HHH-16369 (
https://hibernate.atlassian.net/browse/HHH-16369?atlOrigin=eyJpIjoiMGIxND...
) PostGIS function st_extent(geometry) does not work (
https://hibernate.atlassian.net/browse/HHH-16369?atlOrigin=eyJpIjoiMGIxND...
)
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 in HQL
queries.
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 CrudRepository<GeometryEntity,
UUID> {
@Query(value = "select extent(geometry) from GeometryEntity")
Optional<Polygon> getExtentByHQLQuery();
@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 when using HQL queries.
I have three different queries, two of them are using HQL, the other one is written
native.
None of them work, all results in an error.
The attempt to call {{getExtentByHQLQuery}}() 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 instead of st_extent works on HQL 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
Simple app 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=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100219- sha1:ac3e918 )