Skip to content

Commit 71ae59b

Browse files
committed
Add example
1 parent c2221af commit 71ae59b

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

querydsl-examples/querydsl-example-ksp-codegen/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ repositories {
2020
dependencies {
2121
implementation("jakarta.persistence:jakarta.persistence-api:${jpaVersion}")
2222
implementation("io.github.openfeign.querydsl:querydsl-core:${querydslVersion}")
23+
implementation("io.github.openfeign.querydsl:querydsl-spatial:${querydslVersion}")
2324
implementation("org.hibernate.orm:hibernate-core:${hibernateVersion}")
2425
ksp("io.github.openfeign.querydsl:querydsl-ksp-codegen:${querydslVersion}")
2526
implementation("org.locationtech.jts:jts-core:1.19.0")
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.querydsl.example.ksp
2+
3+
import jakarta.persistence.Entity
4+
import jakarta.persistence.GeneratedValue
5+
import jakarta.persistence.GenerationType
6+
import jakarta.persistence.Id
7+
import org.locationtech.jts.geom.Geometry
8+
9+
@Entity
10+
class MyShape(
11+
@Id
12+
@GeneratedValue(strategy = GenerationType.IDENTITY)
13+
val id: Long = 0,
14+
val departureGeo: Geometry? = null
15+
)

querydsl-examples/querydsl-example-ksp-codegen/src/test/kotlin/Tests.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import com.querydsl.example.ksp.QBearSimplifiedProjection
88
import com.querydsl.example.ksp.QCat
99
import com.querydsl.example.ksp.QDog
1010
import com.querydsl.example.ksp.QGeolocation
11+
import com.querydsl.example.ksp.QMyShape
1112
import com.querydsl.example.ksp.QPerson
1213
import com.querydsl.example.ksp.QPersonClassDTO
1314
import com.querydsl.example.ksp.QPersonClassConstructorDTO
@@ -19,7 +20,9 @@ import org.assertj.core.api.Assertions.assertThat
1920
import org.assertj.core.api.Assertions.fail
2021
import org.hibernate.cfg.Configuration
2122
import kotlin.reflect.full.declaredMemberProperties
23+
import kotlin.reflect.full.memberProperties
2224
import kotlin.reflect.full.primaryConstructor
25+
import kotlin.reflect.jvm.jvmErasure
2326
import kotlin.test.Test
2427

2528
class Tests {
@@ -249,15 +252,12 @@ class Tests {
249252
}
250253
}
251254

252-
@Test
253-
fun `is detecting comparable interface on unknown type`() {
254-
val locationTypeName = QGeolocation::class
255-
.members
256-
.first { it.name == "location" }
257-
.returnType
258-
.toString()
259-
assertThat(locationTypeName).isEqualTo("com.querydsl.core.types.dsl.ComparablePath<org.locationtech.jts.geom.Point>")
260-
}
255+
@Test
256+
fun ensureCorrectGeoType() {
257+
val departureProperty = QMyShape::class.memberProperties.single { it.name == "departureGeo" }
258+
assertThat(departureProperty.returnType.jvmErasure.qualifiedName!!).isEqualTo("com.querydsl.spatial.locationtech.jts.JTSGeometryPath")
259+
assertThat(departureProperty.returnType.arguments.single().type!!.jvmErasure.qualifiedName!!).isEqualTo("org.locationtech.jts.geom.Geometry")
260+
}
261261

262262
private fun initialize(): EntityManagerFactory {
263263
val configuration = Configuration()

0 commit comments

Comments
 (0)