BAEL-3979: Get rid of the Spring Snapshots & Milestones repos (#9434)
This commit is contained in:
parent
0f2212533a
commit
c387fe5dd6
|
@ -14,38 +14,6 @@
|
||||||
<relativePath>../../parent-kotlin</relativePath>
|
<relativePath>../../parent-kotlin</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>spring-snapshots</id>
|
|
||||||
<name>Spring Snapshots</name>
|
|
||||||
<url>https://repo.spring.io/snapshot</url>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>spring-milestones</id>
|
|
||||||
<name>Spring Milestones</name>
|
|
||||||
<url>https://repo.spring.io/milestone</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
|
|
||||||
<pluginRepositories>
|
|
||||||
<pluginRepository>
|
|
||||||
<id>spring-snapshots</id>
|
|
||||||
<name>Spring Snapshots</name>
|
|
||||||
<url>https://repo.spring.io/snapshot</url>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</pluginRepository>
|
|
||||||
<pluginRepository>
|
|
||||||
<id>spring-milestones</id>
|
|
||||||
<name>Spring Milestones</name>
|
|
||||||
<url>https://repo.spring.io/milestone</url>
|
|
||||||
</pluginRepository>
|
|
||||||
</pluginRepositories>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
@ -142,9 +110,9 @@
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<kotlin.version>1.3.31</kotlin.version>
|
<kotlin.version>1.3.31</kotlin.version>
|
||||||
<r2dbc.version>1.0.0.M1</r2dbc.version>
|
<r2dbc.version>1.0.0.RELEASE</r2dbc.version>
|
||||||
<r2dbc-spi.version>1.0.0.M7</r2dbc-spi.version>
|
<r2dbc-spi.version>0.8.2.RELEASE</r2dbc-spi.version>
|
||||||
<h2-r2dbc.version>1.0.0.BUILD-SNAPSHOT</h2-r2dbc.version>
|
<h2-r2dbc.version>0.8.4.RELEASE</h2-r2dbc.version>
|
||||||
<kotlinx-coroutines.version>1.2.1</kotlinx-coroutines.version>
|
<kotlinx-coroutines.version>1.2.1</kotlinx-coroutines.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.baeldung.nonblockingcoroutines.repository
|
package com.baeldung.nonblockingcoroutines.repository
|
||||||
|
|
||||||
import com.baeldung.nonblockingcoroutines.model.Product
|
import com.baeldung.nonblockingcoroutines.model.Product
|
||||||
import org.springframework.data.r2dbc.function.DatabaseClient
|
import org.springframework.data.r2dbc.core.DatabaseClient
|
||||||
import org.springframework.stereotype.Repository
|
import org.springframework.stereotype.Repository
|
||||||
import reactor.core.publisher.Flux
|
import reactor.core.publisher.Flux
|
||||||
import reactor.core.publisher.Mono
|
import reactor.core.publisher.Mono
|
||||||
|
@ -10,7 +10,7 @@ import reactor.core.publisher.Mono
|
||||||
class ProductRepository(private val client: DatabaseClient) {
|
class ProductRepository(private val client: DatabaseClient) {
|
||||||
|
|
||||||
fun getProductById(id: Int): Mono<Product> {
|
fun getProductById(id: Int): Mono<Product> {
|
||||||
return client.execute().sql("SELECT * FROM products WHERE id = $1")
|
return client.execute("SELECT * FROM products WHERE id = $1")
|
||||||
.bind(0, id)
|
.bind(0, id)
|
||||||
.`as`(Product::class.java)
|
.`as`(Product::class.java)
|
||||||
.fetch()
|
.fetch()
|
||||||
|
@ -18,8 +18,7 @@ class ProductRepository(private val client: DatabaseClient) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addNewProduct(name: String, price: Float): Mono<Void> {
|
fun addNewProduct(name: String, price: Float): Mono<Void> {
|
||||||
return client.execute()
|
return client.execute("INSERT INTO products (name, price) VALUES($1, $2)")
|
||||||
.sql("INSERT INTO products (name, price) VALUES($1, $2)")
|
|
||||||
.bind(0, name)
|
.bind(0, name)
|
||||||
.bind(1, price)
|
.bind(1, price)
|
||||||
.then()
|
.then()
|
||||||
|
|
|
@ -6,14 +6,14 @@ import kotlinx.coroutines.FlowPreview
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.reactive.awaitFirstOrNull
|
import kotlinx.coroutines.reactive.awaitFirstOrNull
|
||||||
import kotlinx.coroutines.reactive.flow.asFlow
|
import kotlinx.coroutines.reactive.flow.asFlow
|
||||||
import org.springframework.data.r2dbc.function.DatabaseClient
|
import org.springframework.data.r2dbc.core.DatabaseClient
|
||||||
import org.springframework.stereotype.Repository
|
import org.springframework.stereotype.Repository
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
class ProductRepositoryCoroutines(private val client: DatabaseClient) {
|
class ProductRepositoryCoroutines(private val client: DatabaseClient) {
|
||||||
|
|
||||||
suspend fun getProductById(id: Int): Product? =
|
suspend fun getProductById(id: Int): Product? =
|
||||||
client.execute().sql("SELECT * FROM products WHERE id = $1")
|
client.execute("SELECT * FROM products WHERE id = $1")
|
||||||
.bind(0, id)
|
.bind(0, id)
|
||||||
.`as`(Product::class.java)
|
.`as`(Product::class.java)
|
||||||
.fetch()
|
.fetch()
|
||||||
|
@ -21,8 +21,7 @@ class ProductRepositoryCoroutines(private val client: DatabaseClient) {
|
||||||
.awaitFirstOrNull()
|
.awaitFirstOrNull()
|
||||||
|
|
||||||
suspend fun addNewProduct(name: String, price: Float) =
|
suspend fun addNewProduct(name: String, price: Float) =
|
||||||
client.execute()
|
client.execute("INSERT INTO products (name, price) VALUES($1, $2)")
|
||||||
.sql("INSERT INTO products (name, price) VALUES($1, $2)")
|
|
||||||
.bind(0, name)
|
.bind(0, name)
|
||||||
.bind(1, price)
|
.bind(1, price)
|
||||||
.then()
|
.then()
|
||||||
|
|
Loading…
Reference in New Issue