Unable to resolve name [org.hibernate.spatial.dialect.postgis.PostgisDialect] as strategy [org.hibernate.dialect.Dialect]
Asked Answered
D

5

5
spring.jpa.properties.hibernate.dialect=org.hibernate.spatial.dialect.postgis.PostgisDialect

I have a Spring Boot v1.5 application with Hibernate 5 running a Postgis database. However, I'm having issues with spatial queries, with the exception being Invalid endian flag value encountered.. Searching that exception yields me solutions of adding the appropirate SQL Dialect to the properties file. Doing that, as above, yield me the error from the title.

Running the queries directly in psql makes them work, so it's not an issue in my Postgis DB itself.

The theme of these questions is always a misspelling, but I can't find what it would be here.

Duncandunce answered 5/6, 2019 at 9:45 Comment(2)
You need an additional dependency for the PostgisDialect if you haven't added that to your pom or build file it will not resolve to a class.Antepast
Doh! Post it as an answer, for posterity sake in case junior devs are googling this later on as well :PDuncandunce
A
10

When using the PostgisDialect you will need the hibernate-spatial project on your classpath as a dependency.

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-spatial</artifactId>
    <version>${hibernate.version}</version>
</dependency>

Adding something like the above to your list of dependencies should include the proper classes.

Antepast answered 5/6, 2019 at 10:18 Comment(0)
A
2

Change dialect to

spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQL95Dialect
Amorete answered 2/1, 2023 at 9:47 Comment(0)
M
1

Using Spring Boot 3 and Hibernate 6 (with spatial installed as well), I actually didn't need to explicitly specify that I was using Postgis. It's included automatically in

spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect

if you have hibernate-spatial as a dependency.

Maecenas answered 24/11, 2023 at 9:0 Comment(0)
G
0

Late to the party, but here is my 2 cent:

The org.hibernate.spatial.dialect.postgis.PostgisDialect is already deprecated in later version of hibernate, so you may want to switch to something else, like PostgisPG92Dialect,...

Genaro answered 9/4, 2023 at 5:26 Comment(0)
R
0

The solution that worked for me is:

  1. Add the following starter dependency:
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

This has hibernate-core in it.

  1. Then add the spatial dependency. Caution! Exactly without version:
<dependency>
    <groupId>org.hibernate.orm</groupId>
    <artifactId>hibernate-spatial</artifactId>
</dependency>

And that's it! This approach doesn't require explicit definition of hibernate dialect and at the same fixes the Invalid endian flag value encountered error.

Reeta answered 8/12, 2023 at 7:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.