Skip to content

Instantly share code, notes, and snippets.

@PedroEsnaola
PedroEsnaola / DemoApplication.java
Created April 15, 2019 20:16
R2DBC+CockroachDB
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories;
@SpringBootApplication
@EnableR2dbcRepositories
public class DemoApplication {
@PedroEsnaola
PedroEsnaola / UserController.java
Last active April 15, 2019 22:26
R2DBC+CockroachDB
package com.example.demo.controller;
import com.example.demo.model.User;
import com.example.demo.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@PedroEsnaola
PedroEsnaola / UserRepository.java
Last active April 15, 2019 22:25
R2DBC+CockroachDB
package com.example.demo.repository;
import com.example.demo.model.User;
import org.springframework.data.r2dbc.repository.query.Query;
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;
import reactor.core.publisher.Flux;
@Repository
@PedroEsnaola
PedroEsnaola / User.java
Created April 14, 2019 20:40
R2DB+CockroachDB
package com.example.demo.model;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Table;
@Table("database_user")
public class User {
@Id
@PedroEsnaola
PedroEsnaola / DatabaseConfig.java
Last active April 14, 2019 21:34
R2DBC+CockroachDB
package com.example.demo.config;
import io.r2dbc.pool.ConnectionPool;
import io.r2dbc.pool.ConnectionPoolConfiguration;
import io.r2dbc.postgresql.PostgresqlConnectionConfiguration;
import io.r2dbc.postgresql.PostgresqlConnectionFactory;
import io.r2dbc.spi.Connection;
import io.r2dbc.spi.ConnectionFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.r2dbc.config.AbstractR2dbcConfiguration;
@PedroEsnaola
PedroEsnaola / pom.xml
Last active May 18, 2021 17:23
R2DBC+CockroachDB
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>