0

I'm trying to migrate to Spring Boot 3 (and hibernate-spatial:6.4.1.Final) So before migration i have following lines in my @Entity describing a column in the table storing a MultiLineString geometry:

@Column(name = "multilinestring")
@Type(value = "org.locationtech.jts.geom.MultiLineString")
private MultiLineString multiLineString;

Naively, I'm converting the @Type to @Type(org.locationtech.jts.geom.MultiLineString.class), but this gives an error, because MultiLineString doesn't extend UserType (incompatible types: Class cannot be converted to Class<? extends UserType<?>>)

So which class am I supposed to use in this case? Or what am I doing wrong?

Excerpt from my gradle file in case this matters:

plugins {
    id 'org.springframework.boot' version '3.2.1'
    id 'io.spring.dependency-management' version '1.1.4'
    id 'java'
}
repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-data-rest'
    implementation 'org.springframework.boot:spring-boot-starter-security'
    implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
    implementation 'org.springframework.boot:spring-boot-starter-mail'
    implementation 'org.springframework.boot:spring-boot-starter-validation'
    implementation 'org.hibernate.orm:hibernate-spatial:6.4.1.Final'
    implementation 'net.postgis:postgis-jdbc:2023.1.0'
    implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
    
    ....
}

1 Answer 1

0

Okay, the answer was unexpectedly simple: just remove the @Type annotation:

@Column(name = "multilinestring")
private MultiLineString multiLineString;

after the upgrade to hibernate 6 (and making sure to include implementation 'org.hibernate.orm:hibernate-spatial'in the build.gradle file), JPA correctly recognizes MultiLineString automatically, so the @Type annotation is not needed anymore.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.