Skip to content

Commit 49fd084

Browse files
author
Hyunsik Kang
authored
Implement Reactive (#47)
* implement spring boot 2.6 hibernate-reactive example * Change unnecessarily type casting (apply Generic T Type) * change EntityDsl type interface to class * implement reactive-core module * implement data-reactive-core module * implement hibernate-reactive module * implement test fixture integration-reactive module * persistence.xml xsd file's version up(2.1 -> 2.2) * implement order group equals (for equal comparison) * implement data-hibernate-reactive module * gradle version up 7.4.1 * add gradle build info & stacktrace option * Add workflow to report test results in github actions * github flow's jdk version jdk 8 to 11 * compile option for hibernate-reactive * remove warning, below message 'compileJava' task (current target is 11) and 'compileKotlin' task (current target is 1.8) jvm target compatibility should be set to the same Java version. * Change public members not used externally to private * Change public members not used externally to private * update document for reactive * release version up
1 parent fcba1b7 commit 49fd084

File tree

244 files changed

+12931
-446
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

244 files changed

+12931
-446
lines changed

.github/workflows/build.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ jobs:
1717
runs-on: ubuntu-latest
1818
steps:
1919
- uses: actions/checkout@v2
20-
- name: Set up JDK 8
20+
- name: Set up JDK 11
2121
uses: actions/setup-java@v2
2222
with:
23-
java-version: '8'
23+
java-version: '11'
2424
distribution: 'adopt'
2525
cache: gradle
2626
- name: Validate Gradle wrapper
@@ -33,6 +33,11 @@ jobs:
3333
with:
3434
token: ${{ secrets.CODECOV_TOKEN }}
3535
file: ./build/reports/jacoco/codeCoverageReport/codeCoverageReport.xml
36+
- name: Publish Unit Test Results
37+
uses: EnricoMi/publish-unit-test-result-action@v1
38+
if: always()
39+
with:
40+
files: test-results/**/*.xml
3641
- name: Cleanup Gradle Cache
3742
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
3843
# Restoring these files from a GitHub Actions cache might cause problems for future builds.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ There are several libraries in the easy way to use JPA. However, those libraries
1515

1616
## Quick start
1717

18+
### Reactive
19+
If you are interested in JPA Reactive See [more](./reactive-core/README.md)
20+
1821
### Hibernate
1922

2023
Add Hibernate Kotlin JDSL and Hibernate to dependencies

build.gradle.kts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
2+
import org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED
13
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
24

35
plugins {
@@ -11,7 +13,7 @@ plugins {
1113

1214
allprojects {
1315
group = "com.linecorp.kotlin-jdsl"
14-
version = "1.3.0.RELEASE"
16+
version = "2.0.0.RELEASE"
1517

1618
repositories {
1719
mavenCentral()
@@ -30,8 +32,10 @@ subprojects {
3032

3133
apply<LocalPropertiesPlugin>()
3234

33-
java.sourceCompatibility = JavaVersion.VERSION_1_8
34-
java.targetCompatibility = JavaVersion.VERSION_1_8
35+
val jdk11Required = name.contains("hibernate-reactive")
36+
val javaVersion = if (jdk11Required) JavaVersion.VERSION_11 else JavaVersion.VERSION_1_8
37+
java.sourceCompatibility = javaVersion
38+
java.targetCompatibility = javaVersion
3539

3640
dependencies {
3741
implementation(Dependencies.koltin)
@@ -52,11 +56,18 @@ subprojects {
5256
tasks.withType<KotlinCompile> {
5357
kotlinOptions {
5458
freeCompilerArgs = listOf("-Xjsr305=strict", "-Xjvm-default=all")
55-
jvmTarget = "1.8"
59+
jvmTarget = if (jdk11Required) "11" else "1.8"
5660
}
5761
}
5862

5963
tasks.withType<Test> {
6064
useJUnitPlatform()
65+
testLogging {
66+
showExceptions = true
67+
exceptionFormat = FULL
68+
showCauses = true
69+
showStackTraces = true
70+
events = setOf(FAILED)
71+
}
6172
}
6273
}

buildSrc/build.gradle.kts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2+
13
plugins {
24
`kotlin-dsl`
35
`java-gradle-plugin`
@@ -12,3 +14,10 @@ repositories {
1214

1315
dependencies {
1416
}
17+
18+
tasks.withType<KotlinCompile> {
19+
kotlinOptions {
20+
freeCompilerArgs = listOf("-Xjsr305=strict", "-Xjvm-default=all")
21+
jvmTarget = "11"
22+
}
23+
}

buildSrc/src/main/kotlin/Dependencies.kt

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,27 @@ import org.gradle.api.artifacts.dsl.DependencyHandler
44

55
object Dependencies {
66
const val kotlinVersion = "1.6.10"
7-
const val springCoreVersion = "5.3.15"
8-
const val springBootVersion = "2.6.3"
9-
const val springDataJpa = "2.6.1"
7+
const val springCoreVersion = "5.3.16"
8+
const val springBootVersion = "2.6.4"
9+
const val springDataJpaVersion = "2.6.2"
10+
const val coroutineVersion = "1.6.0"
1011

1112
// kotlin
1213
const val koltin = "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
1314
const val kotlinReflect = "org.jetbrains.kotlin:kotlin-reflect"
1415

1516
// Common
1617
const val javaPersistenceApi = "javax.persistence:javax.persistence-api:2.2"
17-
const val slf4j = "org.slf4j:slf4j-api:1.7.33"
18+
const val slf4j = "org.slf4j:slf4j-api:1.7.36"
1819
const val logback = "ch.qos.logback:logback-classic:1.2.10"
19-
const val hibernate = "org.hibernate:hibernate-core:5.6.4.Final"
20+
const val hibernate = "org.hibernate:hibernate-core:5.6.5.Final"
21+
const val hibernateReactive = "org.hibernate.reactive:hibernate-reactive-core:1.1.3.Final"
2022
const val eclipselink = "org.eclipse.persistence:org.eclipse.persistence.jpa:2.7.10"
2123
const val jacksonKotlinModule = "com.fasterxml.jackson.module:jackson-module-kotlin"
24+
const val agroalPool = "io.agroal:agroal-pool:1.14"
25+
const val vertxJdbcClient = "io.vertx:vertx-jdbc-client:4.2.5"
26+
const val coroutineJdk8 = "org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:$coroutineVersion"
27+
const val coroutineReactor = "org.jetbrains.kotlinx:kotlinx-coroutines-reactor:$coroutineVersion"
2228

2329
// SpringBoot
2430
const val springBootStarter = "org.springframework.boot:spring-boot-starter:${springBootVersion}"
@@ -28,22 +34,27 @@ object Dependencies {
2834
const val springBootBom = "org.springframework.boot:spring-boot-dependencies:${springBootVersion}"
2935

3036
const val springBootWeb = "org.springframework.boot:spring-boot-starter-web:${springBootVersion}"
37+
const val springBootWebflux = "org.springframework.boot:spring-boot-starter-webflux:${springBootVersion}"
3138
const val springBootJpa = "org.springframework.boot:spring-boot-starter-data-jpa:${springBootVersion}"
3239
const val springBootTest = "org.springframework.boot:spring-boot-starter-test:${springBootVersion}"
3340

3441
// Spring
3542
const val springCore = "org.springframework:spring-core:${springCoreVersion}"
3643
const val springBeans = "org.springframework:spring-beans:${springCoreVersion}"
37-
const val springJpa = "org.springframework.data:spring-data-jpa:${springDataJpa}"
38-
const val springBatchInfrastructure = "org.springframework.batch:spring-batch-infrastructure:4.3.4"
44+
const val springJpa = "org.springframework.data:spring-data-jpa:${springDataJpaVersion}"
45+
const val springBatchInfrastructure = "org.springframework.batch:spring-batch-infrastructure:4.3.5"
3946

4047
// Test
4148
const val junit = "org.junit.jupiter:junit-jupiter:5.8.2"
42-
const val assertJ = "org.assertj:assertj-core:3.21.0"
49+
const val assertJ = "org.assertj:assertj-core:3.22.0"
4350
const val mockk = "io.mockk:mockk:1.12.2"
44-
const val springmockk = "com.ninja-squad:springmockk:3.1.0"
4551

4652
const val h2 = "com.h2database:h2:1.4.200"
53+
54+
const val mutinyVersion = "1.4.0"
55+
const val mutinyCore = "io.smallrye.reactive:mutiny:$mutinyVersion"
56+
const val mutinyKotlin = "io.smallrye.reactive:mutiny-kotlin:$mutinyVersion"
57+
val mutiny = listOf(mutinyCore, mutinyKotlin)
4758
}
4859

4960
fun DependencyHandler.api(dependencies: List<Any>) {

buildSrc/src/main/kotlin/JacocoExtensionPlugin.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class JacocoExtensionPlugin : AbstractRootPlugin(apply {
2424

2525
reports {
2626
xml.required.set(true)
27-
html.required.set(false)
27+
html.required.set(true)
2828
csv.required.set(false)
2929
}
3030
}

buildSrc/src/main/kotlin/Modules.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,24 @@ data class Module(
99
@Suppress("unused")
1010
object Modules {
1111
val core = module(":kotlin-jdsl-core")
12+
val reactiveCore = module(":kotlin-jdsl-reactive-core")
1213
val hibernate = module(":hibernate-kotlin-jdsl")
14+
val hibernateReactive = module(":hibernate-reactive-kotlin-jdsl")
1315
val eclipselink = module(":eclipselink-kotlin-jdsl")
1416
val query = module(":kotlin-jdsl-query")
1517

1618
val springDataCore = module(":spring-data-kotlin-jdsl-core")
19+
val springDataReactiveCore = module(":spring-data-kotlin-jdsl-reactive-core")
20+
val springDataHibernateReactive = module(":spring-data-kotlin-jdsl-hibernate-reactive")
1721
val springBatchInfrastructure = module(":spring-batch-kotlin-jdsl-infrastructure")
1822
val springDataAutoconfigure = module(":spring-data-kotlin-jdsl-autoconfigure")
1923
val springDataStarter = module(":spring-data-kotlin-jdsl-starter")
2024

2125
val testFixtureCore = module(":test-fixture-core")
2226
val testFixtureEntity = module(":test-fixture-entity")
2327
val testFixtureIntegration = module(":test-fixture-integration")
28+
val testFixtureIntegrationReactive = module(":test-fixture-integration-reactive")
29+
val testFixtureHibernateReactive = module(":test-fixture-hibernate-reactive")
2430

2531
private fun module(name: String): Module = Module(name)
2632
}

core/src/main/kotlin/com/linecorp/kotlinjdsl/QueryFactory.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@ package com.linecorp.kotlinjdsl
33
import com.linecorp.kotlinjdsl.query.spec.expression.SubqueryExpressionSpec
44
import com.linecorp.kotlinjdsl.querydsl.CriteriaDeleteQueryDsl
55
import com.linecorp.kotlinjdsl.querydsl.CriteriaQueryDsl
6-
import com.linecorp.kotlinjdsl.querydsl.SubqueryDsl
76
import com.linecorp.kotlinjdsl.querydsl.CriteriaUpdateQueryDsl
7+
import com.linecorp.kotlinjdsl.querydsl.SubqueryDsl
88
import javax.persistence.Query
99
import javax.persistence.TypedQuery
1010
import kotlin.reflect.KClass
1111

1212
interface QueryFactory {
13-
@Deprecated(replaceWith = ReplaceWith(expression = "selectQuery"), message = "This method has been replaced with selectQuery.")
13+
@Deprecated(
14+
replaceWith = ReplaceWith(expression = "selectQuery"),
15+
message = "This method has been replaced with selectQuery."
16+
)
1417
fun <T> typedQuery(returnType: Class<T>, dsl: CriteriaQueryDsl<T>.() -> Unit) = selectQuery(returnType, dsl)
1518
fun <T> selectQuery(returnType: Class<T>, dsl: CriteriaQueryDsl<T>.() -> Unit): TypedQuery<T>
16-
fun <T: Any> updateQuery(target: KClass<T>, dsl: CriteriaUpdateQueryDsl.() -> Unit): Query
17-
fun <T: Any> deleteQuery(target: KClass<T>, dsl: CriteriaDeleteQueryDsl.() -> Unit): Query
19+
fun <T : Any> updateQuery(target: KClass<T>, dsl: CriteriaUpdateQueryDsl.() -> Unit): Query
20+
fun <T : Any> deleteQuery(target: KClass<T>, dsl: CriteriaDeleteQueryDsl.() -> Unit): Query
1821
fun <T> subquery(returnType: Class<T>, dsl: SubqueryDsl<T>.() -> Unit): SubqueryExpressionSpec<T>
1922
}

core/src/main/kotlin/com/linecorp/kotlinjdsl/QueryFactoryExtensions.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,19 @@ inline fun <reified T> QueryFactory.streamQuery(
1919
): Stream<T> = selectQuery(T::class.java, dsl).resultStream
2020

2121

22-
@Deprecated(replaceWith = ReplaceWith(expression = "selectQuery"), message = "This method has been replaced with selectQuery.")
22+
@Deprecated(
23+
replaceWith = ReplaceWith(expression = "selectQuery"),
24+
message = "This method has been replaced with selectQuery."
25+
)
2326
inline fun <reified T> QueryFactory.typedQuery(noinline dsl: CriteriaQueryDsl<T>.() -> Unit) = selectQuery(dsl)
2427

2528
inline fun <reified T> QueryFactory.selectQuery(noinline dsl: CriteriaQueryDsl<T>.() -> Unit) =
2629
selectQuery(T::class.java, dsl)
2730

28-
inline fun <reified T: Any> QueryFactory.updateQuery(noinline dsl: CriteriaUpdateQueryDsl.() -> Unit) =
31+
inline fun <reified T : Any> QueryFactory.updateQuery(noinline dsl: CriteriaUpdateQueryDsl.() -> Unit) =
2932
updateQuery(T::class, dsl)
3033

31-
inline fun <reified T: Any> QueryFactory.deleteQuery(noinline dsl: CriteriaDeleteQueryDsl.() -> Unit) =
34+
inline fun <reified T : Any> QueryFactory.deleteQuery(noinline dsl: CriteriaDeleteQueryDsl.() -> Unit) =
3235
deleteQuery(T::class, dsl)
3336

3437
inline fun <reified T> QueryFactory.subquery(noinline dsl: SubqueryDsl<T>.() -> Unit) =

core/src/main/kotlin/com/linecorp/kotlinjdsl/QueryFactoryImpl.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ class QueryFactoryImpl(
2121
return criteriaQueryCreator.createQuery(criteriaQuerySpec)
2222
}
2323

24-
override fun <T: Any> updateQuery(target: KClass<T>, dsl: CriteriaUpdateQueryDsl.() -> Unit): Query {
24+
override fun <T : Any> updateQuery(target: KClass<T>, dsl: CriteriaUpdateQueryDsl.() -> Unit): Query {
2525
return criteriaQueryCreator.createQuery(
2626
QueryDslImpl(target.java).apply(dsl).apply { from(target) }.createCriteriaUpdateQuerySpec()
2727
)
2828
}
2929

30-
override fun <T: Any> deleteQuery(target: KClass<T>, dsl: CriteriaDeleteQueryDsl.() -> Unit): Query {
30+
override fun <T : Any> deleteQuery(target: KClass<T>, dsl: CriteriaDeleteQueryDsl.() -> Unit): Query {
3131
return criteriaQueryCreator.createQuery(
3232
QueryDslImpl(target.java).apply(dsl).apply { from(target) }.createCriteriaDeleteQuerySpec()
3333
)

0 commit comments

Comments
 (0)