├── .github └── workflows │ └── maven.yml ├── .gitignore ├── .project ├── .settings ├── org.eclipse.core.resources.prefs └── org.eclipse.m2e.core.prefs ├── LICENSE ├── README.md ├── codecov.yml ├── core ├── .classpath ├── .project ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.core.prefs │ ├── org.eclipse.m2e.core.prefs │ ├── org.sonarlint.eclipse.core.prefs │ └── org.springframework.ide.eclipse.prefs ├── pom.xml └── src │ ├── main │ ├── java │ │ └── net │ │ │ └── lecousin │ │ │ └── reactive │ │ │ └── data │ │ │ └── relational │ │ │ ├── LcReactiveDataRelationalClient.java │ │ │ ├── LcReactiveDataRelationalInitializer.java │ │ │ ├── LcReactiveDataRelationalRestarter.java │ │ │ ├── annotations │ │ │ ├── ColumnDefinition.java │ │ │ ├── CompositeId.java │ │ │ ├── ForeignKey.java │ │ │ ├── ForeignTable.java │ │ │ ├── GeneratedValue.java │ │ │ ├── Index.java │ │ │ ├── Indexes.java │ │ │ └── JoinTable.java │ │ │ ├── configuration │ │ │ ├── LcR2dbcEntityOperationsBuilder.java │ │ │ └── LcReactiveDataRelationalConfiguration.java │ │ │ ├── enhance │ │ │ ├── ClassPathScanningEntities.java │ │ │ ├── Enhancer.java │ │ │ └── EntityState.java │ │ │ ├── mapping │ │ │ ├── LcEntityReader.java │ │ │ ├── LcEntityWriter.java │ │ │ ├── LcMappingR2dbcConverter.java │ │ │ ├── LcR2dbcMappingContext.java │ │ │ └── LcReactiveDataAccessStrategy.java │ │ │ ├── model │ │ │ ├── CompositeIdValue.java │ │ │ ├── EntityCache.java │ │ │ ├── JoinTableCollectionFromTargetCollection.java │ │ │ ├── JoinTableCollectionToTargetCollection.java │ │ │ ├── ModelAccessException.java │ │ │ ├── ModelException.java │ │ │ ├── ModelUtils.java │ │ │ ├── PrimitiveArraysUtil.java │ │ │ ├── PropertiesSource.java │ │ │ ├── PropertiesSourceMap.java │ │ │ ├── PropertiesSourceRow.java │ │ │ └── metadata │ │ │ │ ├── EntityInstance.java │ │ │ │ ├── EntityMetadata.java │ │ │ │ ├── EntityStaticMetadata.java │ │ │ │ ├── PropertyMetadata.java │ │ │ │ └── PropertyStaticMetadata.java │ │ │ ├── query │ │ │ ├── InsertMultiple.java │ │ │ ├── SelectExecution.java │ │ │ ├── SelectQuery.java │ │ │ ├── SqlQuery.java │ │ │ ├── criteria │ │ │ │ ├── Criteria.java │ │ │ │ ├── CriteriaSqlBuilder.java │ │ │ │ ├── CriteriaVisitor.java │ │ │ │ └── InvalidCriteriaException.java │ │ │ └── operation │ │ │ │ ├── AbstractInstanceProcessor.java │ │ │ │ ├── AbstractProcessor.java │ │ │ │ ├── DeleteProcessor.java │ │ │ │ ├── DeleteWithoutLoading.java │ │ │ │ ├── EntityLoader.java │ │ │ │ ├── Operation.java │ │ │ │ ├── PropertyUpdater.java │ │ │ │ └── SaveProcessor.java │ │ │ ├── repository │ │ │ ├── LcR2dbcEntityTemplate.java │ │ │ ├── LcR2dbcRepository.java │ │ │ ├── LcR2dbcRepositoryFactory.java │ │ │ ├── LcR2dbcRepositoryFactoryBean.java │ │ │ └── LcR2dbcRepositoryImpl.java │ │ │ ├── schema │ │ │ ├── Column.java │ │ │ ├── Index.java │ │ │ ├── RelationalDatabaseSchema.java │ │ │ ├── SchemaBuilderFromEntities.java │ │ │ ├── SchemaException.java │ │ │ ├── Sequence.java │ │ │ ├── Table.java │ │ │ └── dialect │ │ │ │ ├── RelationalDatabaseSchemaDialect.java │ │ │ │ ├── SchemaStatement.java │ │ │ │ └── SchemaStatements.java │ │ │ ├── sql │ │ │ └── ColumnIncrement.java │ │ │ └── util │ │ │ └── Iterables.java │ └── resources │ │ └── META-INF │ │ └── spring.factories │ └── test │ ├── java │ └── net │ │ └── lecousin │ │ └── reactive │ │ └── data │ │ └── relational │ │ ├── test │ │ ├── AbstractBasicTest.java │ │ ├── AbstractLcReactiveDataRelationalTest.java │ │ ├── EntityWithNonNullProperty.java │ │ ├── EntityWithTransientFields.java │ │ ├── arraycolumns │ │ │ ├── AbstractTestArrayColumns.java │ │ │ ├── AllowEnhancer.java │ │ │ ├── EntityWithArrays.java │ │ │ └── EntityWithArraysRepository.java │ │ ├── envelopemodel │ │ │ ├── AbstractTestEnvelopeModel.java │ │ │ ├── AllowEnhancer.java │ │ │ ├── Document.java │ │ │ ├── Envelope.java │ │ │ ├── EnvelopeRepository.java │ │ │ ├── Note.java │ │ │ └── Page.java │ │ ├── manytomanymodel │ │ │ ├── AbstractTestManyToManyModel.java │ │ │ ├── AllowEnhancer.java │ │ │ ├── Entity1.java │ │ │ ├── Entity1Repository.java │ │ │ ├── Entity2.java │ │ │ ├── Entity3.java │ │ │ ├── Entity3Repository.java │ │ │ ├── Entity4.java │ │ │ ├── JoinEntity.java │ │ │ └── package-info.java │ │ ├── model1 │ │ │ ├── AbstractTestModel1.java │ │ │ ├── AllowEnhancer.java │ │ │ ├── Company.java │ │ │ ├── CompanyRepository.java │ │ │ ├── Employee.java │ │ │ ├── Person.java │ │ │ ├── PersonRepository.java │ │ │ ├── PointOfContact.java │ │ │ ├── PostalAddress.java │ │ │ ├── Site.java │ │ │ ├── User.java │ │ │ └── package-info.java │ │ ├── multipleconnections │ │ │ ├── TestMultipleDatabaseConnections.java │ │ │ ├── db1 │ │ │ │ ├── Config1.java │ │ │ │ ├── MultipleDbEntity1.java │ │ │ │ └── MyRepository1.java │ │ │ └── db2 │ │ │ │ ├── Config2.java │ │ │ │ ├── MultipleDbEntity2.java │ │ │ │ └── MyRepository2.java │ │ ├── onetomanymodel │ │ │ ├── AbstractTestOneToManyModel.java │ │ │ ├── AllowEnhancer.java │ │ │ ├── RootEntity.java │ │ │ ├── RootEntityRepository.java │ │ │ ├── RootEntityWithConstructor.java │ │ │ ├── RootEntityWithConstructorRepository.java │ │ │ ├── SubEntity.java │ │ │ ├── SubEntity2.java │ │ │ ├── SubEntity3.java │ │ │ ├── SubEntityWithConstructor.java │ │ │ └── package-info.java │ │ ├── onetoonemodel │ │ │ ├── AbstractTestOneToOneModel.java │ │ │ ├── AllowEnhancer.java │ │ │ ├── MyEntity1.java │ │ │ ├── MyEntity1Repository.java │ │ │ ├── MyEntity1WithConstructor.java │ │ │ ├── MyEntity1WithConstructorRepository.java │ │ │ ├── MyEntity2.java │ │ │ ├── MyEntity2Repository.java │ │ │ ├── MyEntity3.java │ │ │ ├── MyEntity3Repository.java │ │ │ ├── MyEntity4.java │ │ │ ├── MyEntity4Repository.java │ │ │ ├── MyEntity5.java │ │ │ ├── MyEntity6.java │ │ │ ├── MySubEntity1.java │ │ │ ├── MySubEntity1Repository.java │ │ │ ├── MySubEntity1WithConstructor.java │ │ │ ├── MySubEntity2.java │ │ │ ├── MySubEntity3.java │ │ │ ├── MySubEntity4.java │ │ │ ├── MySubEntity5.java │ │ │ ├── MySubEntity5Repository.java │ │ │ ├── MySubEntity6.java │ │ │ ├── MySubEntity6Repository.java │ │ │ └── package-info.java │ │ ├── package-info.java │ │ ├── simplemodel │ │ │ ├── AbstractTestSimpleModel.java │ │ │ ├── AllowEnhancer.java │ │ │ ├── BooleanTypes.java │ │ │ ├── BooleanTypesRepository.java │ │ │ ├── CharacterTypes.java │ │ │ ├── CharacterTypesRepository.java │ │ │ ├── CompositeIdEntity.java │ │ │ ├── DateTypes.java │ │ │ ├── DateTypesRepository.java │ │ │ ├── DateTypesWithTimeZone.java │ │ │ ├── Entity1WithSequence.java │ │ │ ├── Entity2WithSequence.java │ │ │ ├── EnumEntity.java │ │ │ ├── EnumRepository.java │ │ │ ├── NumericTypes.java │ │ │ ├── NumericTypesRepository.java │ │ │ ├── TransactionalService.java │ │ │ ├── UUIDEntity.java │ │ │ ├── UUIDEntityRepository.java │ │ │ ├── UpdatableProperties.java │ │ │ ├── VersionedEntity.java │ │ │ ├── VersionedEntityRepository.java │ │ │ └── package-info.java │ │ └── treemodel │ │ │ ├── AbstractTestTreeModel.java │ │ │ ├── AllowEnhancer.java │ │ │ ├── Node.java │ │ │ ├── NodeRepository.java │ │ │ └── package-info.java │ │ └── tests │ │ ├── MyWrongConfiguration.java │ │ ├── TestClasspathScanning.java │ │ ├── TestCompositeIdValue.java │ │ ├── TestEnhancerErrors.java │ │ ├── TestInsertMultipleToString.java │ │ ├── TestIterables.java │ │ ├── TestModelErrors.java │ │ ├── TestWrongConfiguration.java │ │ ├── invalid │ │ ├── InvalidJoinTable1.java │ │ ├── InvalidJoinTable2.java │ │ ├── InvalidJoinTable3.java │ │ ├── InvalidJoinTable4.java │ │ ├── InvalidJoinTable5.java │ │ ├── InvalidJoinTable6.java │ │ └── NonEntity.java │ │ └── package-info.java │ └── resources │ ├── application.yaml │ ├── lc-reactive-data-relational.yaml │ └── logback-test.xml ├── h2 ├── .classpath ├── .project ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.core.prefs │ ├── org.eclipse.m2e.core.prefs │ ├── org.sonarlint.eclipse.core.prefs │ └── org.springframework.ide.eclipse.prefs ├── pom.xml └── src │ ├── main │ ├── java │ │ └── net │ │ │ └── lecousin │ │ │ └── reactive │ │ │ └── data │ │ │ └── relational │ │ │ └── h2 │ │ │ ├── H2Configuration.java │ │ │ └── H2SchemaDialect.java │ └── resources │ │ └── META-INF │ │ └── services │ │ └── net.lecousin.reactive.data.relational.schema.dialect.RelationalDatabaseSchemaDialect │ └── test │ └── java │ └── net │ └── lecousin │ └── reactive │ └── data │ └── relational │ └── h2 │ └── test │ ├── H2TestConfiguration.java │ ├── TestBasic.java │ ├── TestEnvelopeModel.java │ ├── TestManyToMany.java │ ├── TestModel1.java │ ├── TestMultipleConnections.java │ ├── TestOneToMany.java │ ├── TestOneToOne.java │ ├── TestSimple.java │ └── TestTree.java ├── jacoco-report-aggregate ├── .project ├── .settings │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.m2e.core.prefs └── pom.xml ├── mysql ├── .classpath ├── .project ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.core.prefs │ ├── org.eclipse.m2e.core.prefs │ ├── org.sonarlint.eclipse.core.prefs │ └── org.springframework.ide.eclipse.prefs ├── pom.xml └── src │ ├── main │ ├── java │ │ └── net │ │ │ └── lecousin │ │ │ └── reactive │ │ │ └── data │ │ │ └── relational │ │ │ └── mysql │ │ │ ├── MySqlConfiguration.java │ │ │ └── MySqlSchemaDialect.java │ └── resources │ │ └── META-INF │ │ └── services │ │ └── net.lecousin.reactive.data.relational.schema.dialect.RelationalDatabaseSchemaDialect │ └── test │ └── java │ └── net │ └── lecousin │ └── reactive │ └── data │ └── relational │ └── mysql │ └── test │ ├── MySqlStarter.java │ ├── v5_7_27 │ ├── MySql_v5_7_27_TestConfiguration.java │ ├── TestBasic.java │ ├── TestEnvelopeModel.java │ ├── TestManyToMany.java │ ├── TestModel1.java │ ├── TestMultipleConnections.java │ ├── TestOneToMany.java │ ├── TestOneToOne.java │ ├── TestSimple.java │ └── TestTree.java │ └── v8_0_17 │ ├── MySql_v8_0_17_TestConfiguration.java │ ├── TestBasic.java │ ├── TestEnvelopeModel.java │ ├── TestManyToMany.java │ ├── TestModel1.java │ ├── TestMultipleConnections.java │ ├── TestOneToMany.java │ ├── TestOneToOne.java │ ├── TestSimple.java │ └── TestTree.java ├── pom.xml ├── postgres ├── .classpath ├── .project ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.core.prefs │ ├── org.eclipse.m2e.core.prefs │ ├── org.sonarlint.eclipse.core.prefs │ └── org.springframework.ide.eclipse.prefs ├── pom.xml └── src │ ├── main │ ├── java │ │ └── net │ │ │ └── lecousin │ │ │ └── reactive │ │ │ └── data │ │ │ └── relational │ │ │ └── postgres │ │ │ ├── PostgresConfiguration.java │ │ │ └── PostgresSchemaDialect.java │ └── resources │ │ └── META-INF │ │ └── services │ │ └── net.lecousin.reactive.data.relational.schema.dialect.RelationalDatabaseSchemaDialect │ └── test │ ├── java │ └── net │ │ └── lecousin │ │ └── reactive │ │ └── data │ │ └── relational │ │ └── postgres │ │ └── test │ │ ├── PostgresTestConfiguration.java │ │ ├── TestArrayColumns.java │ │ ├── TestBasic.java │ │ ├── TestEnvelopeModel.java │ │ ├── TestManyToMany.java │ │ ├── TestModel1.java │ │ ├── TestMultipleConnections.java │ │ ├── TestOneToMany.java │ │ ├── TestOneToOne.java │ │ ├── TestSimple.java │ │ ├── TestTree.java │ │ └── geometry │ │ ├── PgGeometryEntity.java │ │ ├── PgGeometryRepository.java │ │ └── TestPgGeometry.java │ └── resources │ └── lc-reactive-data-relational.yaml ├── src └── README.md ├── test-junit-5 ├── .classpath ├── .project ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.core.prefs │ ├── org.eclipse.m2e.core.prefs │ ├── org.sonarlint.eclipse.core.prefs │ └── org.springframework.ide.eclipse.prefs ├── pom.xml └── src │ └── main │ ├── java │ └── net │ │ └── lecousin │ │ └── reactive │ │ └── data │ │ └── relational │ │ └── test │ │ └── LcReactiveDataRelationalTestEngine.java │ └── resources │ └── META-INF │ └── services │ └── org.junit.platform.engine.TestEngine └── test-spring-boot ├── .classpath ├── .project ├── .settings ├── org.eclipse.core.resources.prefs ├── org.eclipse.jdt.core.prefs ├── org.eclipse.m2e.core.prefs └── org.springframework.ide.eclipse.prefs ├── pom.xml └── src └── main ├── java └── myapp │ ├── MyApp.java │ ├── MyRepo.java │ ├── MyService.java │ └── model │ ├── AllowEnhancer.java │ └── MyEntity.java └── resources ├── META-INF └── spring-devtools.properties ├── application.yml └── lc-reactive-data-relational.yaml /.github/workflows/maven.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven 3 | 4 | name: Build 5 | 6 | on: [push, pull_request] 7 | 8 | jobs: 9 | build: 10 | 11 | runs-on: ${{ matrix.os }} 12 | strategy: 13 | matrix: 14 | os: [ 'ubuntu-latest' ] 15 | distribution: [ 'zulu', 'temurin', 'liberica' ] 16 | java: [ '11', '17' ] 17 | name: Build with Java ${{ matrix.java }} (${{ matrix.distribution }}) 18 | 19 | steps: 20 | - name: Checkout 21 | uses: actions/checkout@v2 22 | - name: Set up Java 23 | uses: actions/setup-java@v2 24 | with: 25 | distribution: ${{ matrix.distribution }} 26 | java-version: ${{ matrix.java }} 27 | cache: maven 28 | - name: Build 29 | run: mvn -B compile --file pom.xml 30 | - name: Install dependencies 31 | run: | 32 | sudo echo 'deb http://security.ubuntu.com/ubuntu xenial-security main' | sudo tee -a /etc/apt/sources.list 33 | sudo apt-get update -qq 34 | sudo apt-get install -y libaio1 libevent-dev libssl-dev libssl1.0.0 35 | - name: Test and analysis 36 | run: mvn -B verify --file pom.xml 37 | - name: Upload to Codecov 38 | uses: codecov/codecov-action@v2 39 | with: 40 | files: ./jacoco-report-aggregate/target/site/jacoco-aggregate/jacoco.xml 41 | - name: Upload to Sonar 42 | env: 43 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 44 | SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} 45 | run: mvn -B sonar:sonar -Dsonar.organization=lecousin -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=$SONAR_TOKEN -Dsonar.projectKey=lecousin_lc-spring-data-r2dbc -DprojectName=lc-spring-data-r2dbc -Dsonar.projectName=lc-spring-data-r2dbc 46 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **/target/** 2 | 3 | # IntelliJ 4 | out/ 5 | .idea/ 6 | *.iml -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | net.lecousin.reactive-data-relational.parent 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.m2e.core.maven2Builder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.m2e.core.maven2Nature 16 | 17 | 18 | -------------------------------------------------------------------------------- /.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | range: "65...80" 3 | -------------------------------------------------------------------------------- /core/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /core/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | net.lecousin.reactive-data-relational.core 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.springframework.ide.eclipse.boot.validation.springbootbuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.m2e.core.maven2Builder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.jdt.core.javanature 26 | org.eclipse.m2e.core.maven2Nature 27 | 28 | 29 | -------------------------------------------------------------------------------- /core/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding//src/test/java=UTF-8 5 | encoding//src/test/resources=UTF-8 6 | encoding/=UTF-8 7 | -------------------------------------------------------------------------------- /core/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 3 | org.eclipse.jdt.core.compiler.compliance=11 4 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 5 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 6 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore 7 | org.eclipse.jdt.core.compiler.release=enabled 8 | org.eclipse.jdt.core.compiler.source=11 9 | -------------------------------------------------------------------------------- /core/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /core/.settings/org.sonarlint.eclipse.core.prefs: -------------------------------------------------------------------------------- 1 | autoEnabled=true 2 | eclipse.preferences.version=1 3 | idePrefixKey= 4 | projectKey=lecousin_lc-spring-data-r2dbc 5 | serverId=SonarCloud/lecousin 6 | sqPrefixKey=core 7 | -------------------------------------------------------------------------------- /core/.settings/org.springframework.ide.eclipse.prefs: -------------------------------------------------------------------------------- 1 | boot.validation.initialized=true 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /core/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | net.lecousin.reactive-data-relational 5 | parent 6 | 0.10.2 7 | 8 | core 9 | 10 | 11 | ${project.basedir}/../jacoco-report-aggregate/target/site/jacoco-aggregate/jacoco.xml 12 | 13 | 14 | 15 | 16 | org.springframework.boot 17 | spring-boot-starter-data-r2dbc 18 | ${spring-boot.version} 19 | 20 | 21 | 22 | org.apache.commons 23 | commons-lang3 24 | 25 | 26 | 27 | org.javassist 28 | javassist 29 | 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-devtools 34 | ${spring-boot.version} 35 | true 36 | compile 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | org.apache.maven.plugins 45 | maven-jar-plugin 46 | 47 | 48 | 49 | test-jar 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /core/src/main/java/net/lecousin/reactive/data/relational/annotations/ColumnDefinition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package net.lecousin.reactive.data.relational.annotations; 15 | 16 | import java.lang.annotation.ElementType; 17 | import java.lang.annotation.Retention; 18 | import java.lang.annotation.RetentionPolicy; 19 | import java.lang.annotation.Target; 20 | 21 | import org.springframework.data.relational.core.mapping.Column; 22 | 23 | /** 24 | * Allow to specify information about a column to generate the schema. 25 | * 26 | * @author Guillaume Le Cousin 27 | */ 28 | @Retention(RetentionPolicy.RUNTIME) 29 | @Target({ ElementType.FIELD }) 30 | @Column 31 | public @interface ColumnDefinition { 32 | 33 | /** Defines is the column may contain NULL or not. */ 34 | boolean nullable() default true; 35 | /** Defines if the value may be updated or not. */ 36 | boolean updatable() default true; 37 | 38 | /** Minimum value or length. */ 39 | long min() default 0; 40 | /** Maximum value or length. */ 41 | long max() default -1; 42 | 43 | /** Floating-point precision. */ 44 | int precision() default -1; 45 | /** Floating-point scale. */ 46 | int scale() default -1; 47 | 48 | } 49 | -------------------------------------------------------------------------------- /core/src/main/java/net/lecousin/reactive/data/relational/annotations/CompositeId.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package net.lecousin.reactive.data.relational.annotations; 15 | 16 | import java.lang.annotation.ElementType; 17 | import java.lang.annotation.Retention; 18 | import java.lang.annotation.RetentionPolicy; 19 | import java.lang.annotation.Target; 20 | 21 | /** 22 | * For entities without an @Id property, specifies the columns to use as a unique key. 23 | * 24 | * @author Guillaume Le Cousin 25 | */ 26 | @Retention(RetentionPolicy.RUNTIME) 27 | @Target({ ElementType.TYPE }) 28 | public @interface CompositeId { 29 | 30 | String indexName(); 31 | 32 | String[] properties(); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /core/src/main/java/net/lecousin/reactive/data/relational/annotations/ForeignTable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package net.lecousin.reactive.data.relational.annotations; 15 | 16 | import java.lang.annotation.ElementType; 17 | import java.lang.annotation.Retention; 18 | import java.lang.annotation.RetentionPolicy; 19 | import java.lang.annotation.Target; 20 | 21 | import org.springframework.data.annotation.Transient; 22 | 23 | /** 24 | * Indicates a foreign key exists on the linked entity. 25 | * It is transient, meaning there is no corresponding column for this attribute. 26 | * 27 | * @author Guillaume Le Cousin 28 | */ 29 | @Retention(RetentionPolicy.RUNTIME) 30 | @Target({ ElementType.FIELD }) 31 | @Transient 32 | public @interface ForeignTable { 33 | 34 | /** 35 | * Indicates which attribute in the linked entity is the foreign key to use for this link. 36 | */ 37 | String joinKey(); 38 | 39 | /** 40 | * Specifies if the link is optional or not. 41 | * If not optional, it means it should always exist a linked entity with a foreign key linked to this entity. 42 | */ 43 | boolean optional() default true; 44 | 45 | } 46 | -------------------------------------------------------------------------------- /core/src/main/java/net/lecousin/reactive/data/relational/annotations/GeneratedValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package net.lecousin.reactive.data.relational.annotations; 15 | 16 | import java.lang.annotation.ElementType; 17 | import java.lang.annotation.Retention; 18 | import java.lang.annotation.RetentionPolicy; 19 | import java.lang.annotation.Target; 20 | 21 | /** 22 | * Indicates a value being generated by the database system. 23 | * 24 | * @author Guillaume Le Cousin 25 | */ 26 | @Retention(RetentionPolicy.RUNTIME) 27 | @Target({ ElementType.FIELD }) 28 | public @interface GeneratedValue { 29 | 30 | enum Strategy { 31 | /** Use auto increment/serial capability from database. */ 32 | AUTO_INCREMENT, 33 | /** Use a sequence. Sequence name must be specified. */ 34 | SEQUENCE, 35 | /** Generate a random UUID. Must be used only with a column of type java.util.UUID. */ 36 | RANDOM_UUID; 37 | } 38 | 39 | /** Strategy to generate the value. */ 40 | Strategy strategy() default Strategy.AUTO_INCREMENT; 41 | 42 | /** For SEQUENCE strategy, specifies the name of the sequence to use. */ 43 | String sequence() default ""; 44 | 45 | } 46 | -------------------------------------------------------------------------------- /core/src/main/java/net/lecousin/reactive/data/relational/annotations/Index.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package net.lecousin.reactive.data.relational.annotations; 15 | 16 | import java.lang.annotation.ElementType; 17 | import java.lang.annotation.Repeatable; 18 | import java.lang.annotation.Retention; 19 | import java.lang.annotation.RetentionPolicy; 20 | import java.lang.annotation.Target; 21 | 22 | /** 23 | * Define an index on a table. 24 | * 25 | * @author Guillaume Le Cousin 26 | */ 27 | @Retention(RetentionPolicy.RUNTIME) 28 | @Target({ ElementType.TYPE }) 29 | @Repeatable(Indexes.class) 30 | public @interface Index { 31 | 32 | String name(); 33 | 34 | String[] properties(); 35 | 36 | boolean unique() default false; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /core/src/main/java/net/lecousin/reactive/data/relational/annotations/Indexes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package net.lecousin.reactive.data.relational.annotations; 15 | 16 | import java.lang.annotation.ElementType; 17 | import java.lang.annotation.Retention; 18 | import java.lang.annotation.RetentionPolicy; 19 | import java.lang.annotation.Target; 20 | 21 | /** 22 | * List of indexes. 23 | * 24 | * @author Guillaume Le Cousin 25 | */ 26 | @Retention(RetentionPolicy.RUNTIME) 27 | @Target({ ElementType.TYPE }) 28 | public @interface Indexes { 29 | 30 | Index[] value(); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /core/src/main/java/net/lecousin/reactive/data/relational/mapping/LcReactiveDataAccessStrategy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package net.lecousin.reactive.data.relational.mapping; 15 | 16 | import java.util.function.BiFunction; 17 | 18 | import org.springframework.data.r2dbc.core.DefaultReactiveDataAccessStrategy; 19 | import org.springframework.data.r2dbc.dialect.R2dbcDialect; 20 | 21 | import io.r2dbc.spi.Row; 22 | import io.r2dbc.spi.RowMetadata; 23 | import net.lecousin.reactive.data.relational.model.PropertiesSourceRow; 24 | 25 | /** 26 | * 27 | * @author Guillaume Le Cousin 28 | * 29 | */ 30 | public class LcReactiveDataAccessStrategy extends DefaultReactiveDataAccessStrategy { 31 | 32 | protected R2dbcDialect dialect; 33 | 34 | public LcReactiveDataAccessStrategy(R2dbcDialect dialect, LcMappingR2dbcConverter converter) { 35 | super(dialect, converter); 36 | this.dialect = dialect; 37 | } 38 | 39 | @Override 40 | public BiFunction getRowMapper(Class typeToRead) { 41 | LcEntityReader reader = new LcEntityReader(null, (LcMappingR2dbcConverter)getConverter()); 42 | return (row, metadata) -> reader.read(typeToRead, new PropertiesSourceRow(row, metadata)); 43 | } 44 | 45 | public R2dbcDialect getDialect() { 46 | return dialect; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /core/src/main/java/net/lecousin/reactive/data/relational/model/ModelAccessException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package net.lecousin.reactive.data.relational.model; 15 | 16 | /** 17 | * Runtime exception thrown when an error occurred while accessing entities. 18 | * 19 | * @author Guillaume Le Cousin 20 | * 21 | */ 22 | public class ModelAccessException extends RuntimeException { 23 | 24 | private static final long serialVersionUID = 1L; 25 | 26 | public ModelAccessException(String message, Throwable cause) { 27 | super(message, cause); 28 | } 29 | 30 | public ModelAccessException(String message) { 31 | super(message); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /core/src/main/java/net/lecousin/reactive/data/relational/model/ModelException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package net.lecousin.reactive.data.relational.model; 15 | 16 | /** 17 | * Invalid entity model. 18 | * 19 | * @author Guillaume Le Cousin 20 | * 21 | */ 22 | public class ModelException extends Exception { 23 | 24 | private static final long serialVersionUID = 1L; 25 | 26 | public ModelException(String message) { 27 | super(message); 28 | } 29 | 30 | public ModelException(String message, Throwable cause) { 31 | super(message, cause); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /core/src/main/java/net/lecousin/reactive/data/relational/model/PropertiesSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package net.lecousin.reactive.data.relational.model; 15 | 16 | import org.springframework.data.relational.core.mapping.RelationalPersistentProperty; 17 | 18 | /** 19 | * Interface for a source of properties (for example from a row in database). 20 | * 21 | * @author Guillaume Le Cousin 22 | * 23 | */ 24 | public interface PropertiesSource { 25 | 26 | Object getSource(); 27 | 28 | Object getPropertyValue(RelationalPersistentProperty property); 29 | 30 | boolean isPropertyPresent(RelationalPersistentProperty property); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /core/src/main/java/net/lecousin/reactive/data/relational/model/PropertiesSourceMap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package net.lecousin.reactive.data.relational.model; 15 | 16 | import java.util.Map; 17 | 18 | import org.springframework.data.relational.core.mapping.RelationalPersistentProperty; 19 | 20 | /** 21 | * Implementation of PropertiesSource from a map of values. 22 | * 23 | * @author Guillaume Le Cousin 24 | * 25 | */ 26 | public class PropertiesSourceMap implements PropertiesSource { 27 | 28 | private Map map; 29 | private Map aliases; 30 | 31 | public PropertiesSourceMap(Map map, Map aliases) { 32 | this.map = map; 33 | this.aliases = aliases; 34 | } 35 | 36 | @Override 37 | public Object getSource() { 38 | return map; 39 | } 40 | 41 | @Override 42 | public boolean isPropertyPresent(RelationalPersistentProperty property) { 43 | String alias = aliases.get(property.getName()); 44 | return alias != null && map.containsKey(alias); 45 | } 46 | 47 | @Override 48 | public Object getPropertyValue(RelationalPersistentProperty property) { 49 | return map.get(aliases.get(property.getName())); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /core/src/main/java/net/lecousin/reactive/data/relational/model/PropertiesSourceRow.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package net.lecousin.reactive.data.relational.model; 15 | 16 | import org.springframework.data.relational.core.mapping.RelationalPersistentProperty; 17 | import org.springframework.lang.NonNull; 18 | 19 | import io.r2dbc.spi.Row; 20 | import io.r2dbc.spi.RowMetadata; 21 | 22 | /** 23 | * Implementation of PropertiesSource from a row returned by the database. 24 | * 25 | * @author Guillaume Le Cousin 26 | * 27 | */ 28 | public class PropertiesSourceRow implements PropertiesSource { 29 | 30 | private Row row; 31 | private RowMetadata metadata; 32 | 33 | public PropertiesSourceRow(Row row, @NonNull RowMetadata metadata) { 34 | this.row = row; 35 | this.metadata = metadata; 36 | } 37 | 38 | @Override 39 | public Object getSource() { 40 | return row; 41 | } 42 | 43 | @Override 44 | public boolean isPropertyPresent(RelationalPersistentProperty property) { 45 | try { 46 | metadata.getColumnMetadata(property.getColumnName().getReference()); 47 | return true; 48 | } catch (Exception e) { 49 | return false; 50 | } 51 | } 52 | 53 | @Override 54 | public Object getPropertyValue(RelationalPersistentProperty property) { 55 | return row.get(property.getColumnName().getReference()); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /core/src/main/java/net/lecousin/reactive/data/relational/query/criteria/CriteriaVisitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package net.lecousin.reactive.data.relational.query.criteria; 15 | 16 | import net.lecousin.reactive.data.relational.query.criteria.Criteria.And; 17 | import net.lecousin.reactive.data.relational.query.criteria.Criteria.Or; 18 | 19 | /** 20 | * Interface using the visitor pattern to go through criteria tree. 21 | * 22 | * @author Guillaume Le Cousin 23 | * 24 | * @param type of value returned by the visitor 25 | */ 26 | public interface CriteriaVisitor { 27 | 28 | T visit(Criteria.And and); 29 | 30 | T visit(Criteria.Or or); 31 | 32 | T visit(Criteria.PropertyOperation op); 33 | 34 | public abstract static class SearchVisitor implements CriteriaVisitor { 35 | @Override 36 | public Boolean visit(And and) { 37 | return Boolean.valueOf(and.getLeft().accept(this).booleanValue() || and.getRight().accept(this).booleanValue()); 38 | } 39 | 40 | @Override 41 | public Boolean visit(Or or) { 42 | return Boolean.valueOf(or.getLeft().accept(this).booleanValue() || or.getRight().accept(this).booleanValue()); 43 | } 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /core/src/main/java/net/lecousin/reactive/data/relational/query/criteria/InvalidCriteriaException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package net.lecousin.reactive.data.relational.query.criteria; 15 | 16 | /** 17 | * Exception thrown when a criteria cannot be processed. 18 | * 19 | * @author Guillaume Le Cousin 20 | * 21 | */ 22 | public class InvalidCriteriaException extends RuntimeException { 23 | 24 | private static final long serialVersionUID = 1L; 25 | 26 | public InvalidCriteriaException(String message) { 27 | super(message); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/net/lecousin/reactive/data/relational/repository/LcR2dbcEntityTemplate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package net.lecousin.reactive.data.relational.repository; 15 | 16 | import org.springframework.data.r2dbc.core.R2dbcEntityTemplate; 17 | 18 | import net.lecousin.reactive.data.relational.LcReactiveDataRelationalClient; 19 | 20 | /** 21 | * Helper class to execute database operations. 22 | * 23 | * @author Guillaume Le Cousin 24 | * 25 | */ 26 | public class LcR2dbcEntityTemplate extends R2dbcEntityTemplate { 27 | 28 | private LcReactiveDataRelationalClient lcClient; 29 | 30 | public LcR2dbcEntityTemplate(LcReactiveDataRelationalClient lcClient) { 31 | super(lcClient.getSpringClient(), lcClient.getDataAccess()); 32 | this.lcClient = lcClient; 33 | } 34 | 35 | public LcReactiveDataRelationalClient getLcClient() { 36 | return lcClient; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /core/src/main/java/net/lecousin/reactive/data/relational/repository/LcR2dbcRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package net.lecousin.reactive.data.relational.repository; 15 | 16 | import org.springframework.data.r2dbc.repository.R2dbcRepository; 17 | import org.springframework.data.repository.NoRepositoryBean; 18 | 19 | import net.lecousin.reactive.data.relational.LcReactiveDataRelationalClient; 20 | 21 | /** 22 | * Base interface for a Spring data repository extended with functionalities from this library. 23 | * 24 | * @author Guillaume Le Cousin 25 | * 26 | * @param type of entity 27 | * @param type of primary key 28 | */ 29 | @NoRepositoryBean 30 | @SuppressWarnings("java:S119") // name of parameter ID 31 | public interface LcR2dbcRepository extends R2dbcRepository { 32 | 33 | LcReactiveDataRelationalClient getLcClient(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /core/src/main/java/net/lecousin/reactive/data/relational/repository/LcR2dbcRepositoryFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package net.lecousin.reactive.data.relational.repository; 15 | 16 | import org.springframework.data.r2dbc.core.R2dbcEntityOperations; 17 | import org.springframework.data.r2dbc.repository.support.R2dbcRepositoryFactory; 18 | import org.springframework.data.repository.core.RepositoryMetadata; 19 | 20 | /** 21 | * Spring data repository factory. 22 | * 23 | * @author Guillaume Le Cousin 24 | * 25 | */ 26 | public class LcR2dbcRepositoryFactory extends R2dbcRepositoryFactory { 27 | 28 | public LcR2dbcRepositoryFactory(R2dbcEntityOperations operations) { 29 | super(operations); 30 | } 31 | 32 | @Override 33 | protected Class getRepositoryBaseClass(RepositoryMetadata metadata) { 34 | return LcR2dbcRepositoryImpl.class; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /core/src/main/java/net/lecousin/reactive/data/relational/repository/LcR2dbcRepositoryFactoryBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package net.lecousin.reactive.data.relational.repository; 15 | 16 | import java.io.Serializable; 17 | 18 | import org.springframework.data.r2dbc.core.R2dbcEntityOperations; 19 | import org.springframework.data.r2dbc.repository.support.R2dbcRepositoryFactoryBean; 20 | import org.springframework.data.repository.Repository; 21 | import org.springframework.data.repository.core.support.RepositoryFactorySupport; 22 | 23 | /** 24 | * Spring data repository factory. 25 | * 26 | * @author Guillaume Le Cousin 27 | * 28 | * @param type of repository 29 | * @param type of entity 30 | * @param type of primary key 31 | */ 32 | @SuppressWarnings("java:S119") // name of parameter ID 33 | public class LcR2dbcRepositoryFactoryBean, S, ID extends Serializable> extends R2dbcRepositoryFactoryBean { 34 | 35 | public LcR2dbcRepositoryFactoryBean(Class repositoryInterface) { 36 | super(repositoryInterface); 37 | } 38 | 39 | @Override 40 | protected RepositoryFactorySupport getFactoryInstance(R2dbcEntityOperations operations) { 41 | return new LcR2dbcRepositoryFactory(operations); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /core/src/main/java/net/lecousin/reactive/data/relational/schema/Index.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package net.lecousin.reactive.data.relational.schema; 15 | 16 | import java.util.LinkedList; 17 | import java.util.List; 18 | 19 | import org.springframework.data.relational.core.sql.IdentifierProcessing; 20 | 21 | /** 22 | * Represent an index on columns in a database schema. 23 | * 24 | * @author Guillaume Le Cousin 25 | * 26 | */ 27 | public class Index { 28 | 29 | private String name; 30 | private IdentifierProcessing idProcessing; 31 | private List columns = new LinkedList<>(); 32 | private boolean unique; 33 | 34 | public Index(String name, IdentifierProcessing idProcessing) { 35 | this.name = name; 36 | this.idProcessing = idProcessing; 37 | } 38 | 39 | public void addColumn(Column col) { 40 | columns.add(col); 41 | } 42 | 43 | public boolean isUnique() { 44 | return unique; 45 | } 46 | 47 | public void setUnique(boolean unique) { 48 | this.unique = unique; 49 | } 50 | 51 | public String toSql() { 52 | return idProcessing.quote(name); 53 | } 54 | 55 | public String getReferenceName() { 56 | return name; 57 | } 58 | 59 | public List getColumns() { 60 | return columns; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /core/src/main/java/net/lecousin/reactive/data/relational/schema/RelationalDatabaseSchema.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package net.lecousin.reactive.data.relational.schema; 15 | 16 | import java.util.LinkedList; 17 | import java.util.List; 18 | import java.util.NoSuchElementException; 19 | 20 | /** 21 | * Database schema, with tables and sequences. 22 | * 23 | * @author Guillaume Le Cousin 24 | * 25 | */ 26 | public class RelationalDatabaseSchema { 27 | 28 | private List tables = new LinkedList<>(); 29 | private List sequences = new LinkedList<>(); 30 | 31 | public void add(Table table) { 32 | tables.add(table); 33 | } 34 | 35 | public List
getTables() { 36 | return tables; 37 | } 38 | 39 | public Table getTable(String name) { 40 | for (Table table : tables) 41 | if (table.getReferenceName().equalsIgnoreCase(name)) 42 | return table; 43 | throw new NoSuchElementException("Table " + name); 44 | } 45 | 46 | public void add(Sequence sequence) { 47 | sequences.add(sequence); 48 | } 49 | 50 | public List getSequences() { 51 | return sequences; 52 | } 53 | 54 | public Sequence getSequence(String name) { 55 | for (Sequence sequence : sequences) 56 | if (sequence.getReferenceName().equalsIgnoreCase(name)) 57 | return sequence; 58 | throw new NoSuchElementException("Sequence " + name); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /core/src/main/java/net/lecousin/reactive/data/relational/schema/SchemaException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package net.lecousin.reactive.data.relational.schema; 15 | 16 | /** 17 | * Runtime exception raised if the schema cannot be generated. 18 | * 19 | * @author Guillaume Le Cousin 20 | */ 21 | public class SchemaException extends RuntimeException { 22 | 23 | private static final long serialVersionUID = 1L; 24 | 25 | public SchemaException(String message) { 26 | super(message); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /core/src/main/java/net/lecousin/reactive/data/relational/schema/Sequence.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package net.lecousin.reactive.data.relational.schema; 15 | 16 | import org.springframework.data.relational.core.sql.IdentifierProcessing; 17 | 18 | /** 19 | * A sequence in a database schema. 20 | * 21 | * @author Guillaume Le Cousin 22 | * 23 | */ 24 | public class Sequence { 25 | 26 | private String name; 27 | private IdentifierProcessing idProcessing; 28 | 29 | public Sequence(String name, IdentifierProcessing idProcessing) { 30 | this.name = name; 31 | this.idProcessing = idProcessing; 32 | } 33 | 34 | public String toSql() { 35 | return idProcessing.quote(name); 36 | } 37 | 38 | public String getReferenceName() { 39 | return name; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /core/src/main/java/net/lecousin/reactive/data/relational/schema/dialect/SchemaStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * https://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package net.lecousin.reactive.data.relational.schema.dialect; 15 | 16 | import java.util.HashSet; 17 | import java.util.List; 18 | import java.util.Set; 19 | 20 | /** 21 | * A schema statement (create table, add constraints, add index ...). 22 | * 23 | * @author Guillaume Le Cousin 24 | * 25 | */ 26 | public class SchemaStatement { 27 | 28 | private String sql; 29 | private Set dependencies = new HashSet<>(); 30 | private Set doNotExecuteTogether = new HashSet<>(); 31 | 32 | public SchemaStatement(String sql) { 33 | this.sql = sql; 34 | } 35 | 36 | public void addDependency(SchemaStatement dependsOn) { 37 | dependencies.add(dependsOn); 38 | } 39 | 40 | public void removeDependency(SchemaStatement statement) { 41 | dependencies.remove(statement); 42 | } 43 | 44 | public boolean hasDependency() { 45 | return !dependencies.isEmpty(); 46 | } 47 | 48 | public void doNotExecuteTogether(SchemaStatement statement) { 49 | doNotExecuteTogether.add(statement); 50 | } 51 | 52 | public boolean canExecuteWith(List statements) { 53 | return doNotExecuteTogether.stream().noneMatch(statements::contains); 54 | } 55 | 56 | public String getSql() { 57 | return sql; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /core/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.context.ApplicationListener=net.lecousin.reactive.data.relational.LcReactiveDataRelationalRestarter 2 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/EntityWithNonNullProperty.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.relational.core.mapping.Table; 5 | 6 | import net.lecousin.reactive.data.relational.annotations.ColumnDefinition; 7 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 8 | 9 | @Table 10 | public class EntityWithNonNullProperty { 11 | 12 | @Id @GeneratedValue 13 | private Long id; 14 | 15 | @ColumnDefinition(nullable = false) 16 | private Boolean nonNullable; 17 | 18 | public Long getId() { 19 | return id; 20 | } 21 | 22 | public void setId(Long id) { 23 | this.id = id; 24 | } 25 | 26 | public Boolean getNonNullable() { 27 | return nonNullable; 28 | } 29 | 30 | public void setNonNullable(Boolean nonNullable) { 31 | this.nonNullable = nonNullable; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/EntityWithTransientFields.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.data.annotation.Transient; 6 | import org.springframework.data.relational.core.mapping.Column; 7 | import org.springframework.data.relational.core.mapping.Table; 8 | 9 | import net.lecousin.reactive.data.relational.LcReactiveDataRelationalClient; 10 | 11 | @Table("basic") 12 | public class EntityWithTransientFields { 13 | 14 | @Column 15 | private String str; 16 | 17 | @Transient 18 | private String textNotSaved; 19 | 20 | @Value("${test:hello}") 21 | private String defaultHello; 22 | 23 | @Autowired(required = false) 24 | private LcReactiveDataRelationalClient client; 25 | 26 | public String getStr() { 27 | return str; 28 | } 29 | 30 | public void setStr(String str) { 31 | this.str = str; 32 | } 33 | 34 | public String getTextNotSaved() { 35 | return textNotSaved; 36 | } 37 | 38 | public void setTextNotSaved(String textNotSaved) { 39 | this.textNotSaved = textNotSaved; 40 | } 41 | 42 | public String getDefaultHello() { 43 | return defaultHello; 44 | } 45 | 46 | public void setDefaultHello(String defaultHello) { 47 | this.defaultHello = defaultHello; 48 | } 49 | 50 | public LcReactiveDataRelationalClient getClient() { 51 | return client; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/arraycolumns/AllowEnhancer.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.arraycolumns; 2 | 3 | public interface AllowEnhancer { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/arraycolumns/EntityWithArraysRepository.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.arraycolumns; 2 | 3 | import net.lecousin.reactive.data.relational.repository.LcR2dbcRepository; 4 | 5 | public interface EntityWithArraysRepository extends LcR2dbcRepository { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/envelopemodel/AllowEnhancer.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.envelopemodel; 2 | 3 | public interface AllowEnhancer { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/envelopemodel/Document.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.envelopemodel; 2 | 3 | import java.util.Set; 4 | 5 | import org.springframework.data.annotation.Id; 6 | import org.springframework.data.relational.core.mapping.Column; 7 | import org.springframework.data.relational.core.mapping.Table; 8 | 9 | import net.lecousin.reactive.data.relational.annotations.ForeignKey; 10 | import net.lecousin.reactive.data.relational.annotations.ForeignKey.OnForeignDeleted; 11 | import net.lecousin.reactive.data.relational.annotations.ForeignTable; 12 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 13 | 14 | @Table("edm_doc") 15 | public class Document { 16 | 17 | @Id @GeneratedValue 18 | private Long id; 19 | 20 | @ForeignKey(optional = false, cascadeDelete = false, onForeignDeleted = OnForeignDeleted.DELETE) 21 | private Envelope envelope; 22 | 23 | @Column 24 | private String documentType; 25 | 26 | @ForeignTable(joinKey = "document", optional = false) 27 | private Set pages; 28 | 29 | @ForeignTable(joinKey = "document", optional = true) 30 | private Set notes; 31 | 32 | public Envelope getEnvelope() { 33 | return envelope; 34 | } 35 | 36 | public void setEnvelope(Envelope envelope) { 37 | this.envelope = envelope; 38 | } 39 | 40 | public String getDocumentType() { 41 | return documentType; 42 | } 43 | 44 | public void setDocumentType(String documentType) { 45 | this.documentType = documentType; 46 | } 47 | 48 | public Set getPages() { 49 | return pages; 50 | } 51 | 52 | public void setPages(Set pages) { 53 | this.pages = pages; 54 | } 55 | 56 | public Long getId() { 57 | return id; 58 | } 59 | 60 | public Set getNotes() { 61 | return notes; 62 | } 63 | 64 | public void setNotes(Set notes) { 65 | this.notes = notes; 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/envelopemodel/Envelope.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.envelopemodel; 2 | 3 | import java.time.LocalDate; 4 | import java.util.Set; 5 | 6 | import org.springframework.data.annotation.Id; 7 | import org.springframework.data.relational.core.mapping.Column; 8 | import org.springframework.data.relational.core.mapping.Table; 9 | 10 | import net.lecousin.reactive.data.relational.annotations.ForeignTable; 11 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 12 | 13 | @Table("edm_envelope") 14 | public class Envelope { 15 | 16 | @Id @GeneratedValue 17 | private Long id; 18 | 19 | @Column 20 | private LocalDate receiveDate; 21 | 22 | @ForeignTable(joinKey = "envelope", optional = false) 23 | private Set documents; 24 | 25 | @ForeignTable(joinKey = "envelope", optional = true) 26 | private Set notes; 27 | 28 | public LocalDate getReceiveDate() { 29 | return receiveDate; 30 | } 31 | 32 | public void setReceiveDate(LocalDate receiveDate) { 33 | this.receiveDate = receiveDate; 34 | } 35 | 36 | public Set getDocuments() { 37 | return documents; 38 | } 39 | 40 | public void setDocuments(Set documents) { 41 | this.documents = documents; 42 | } 43 | 44 | public Long getId() { 45 | return id; 46 | } 47 | 48 | public Set getNotes() { 49 | return notes; 50 | } 51 | 52 | public void setNotes(Set notes) { 53 | this.notes = notes; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/envelopemodel/EnvelopeRepository.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.envelopemodel; 2 | 3 | import net.lecousin.reactive.data.relational.repository.LcR2dbcRepository; 4 | 5 | public interface EnvelopeRepository extends LcR2dbcRepository { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/envelopemodel/Note.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.envelopemodel; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.relational.core.mapping.Column; 5 | import org.springframework.data.relational.core.mapping.Table; 6 | 7 | import net.lecousin.reactive.data.relational.annotations.ForeignKey; 8 | import net.lecousin.reactive.data.relational.annotations.ForeignKey.OnForeignDeleted; 9 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 10 | 11 | @Table("edm_note") 12 | public class Note { 13 | 14 | @Id @GeneratedValue 15 | private Long id; 16 | 17 | @ForeignKey(optional = true, cascadeDelete = false, onForeignDeleted = OnForeignDeleted.DELETE) 18 | private Envelope envelope; 19 | 20 | @ForeignKey(optional = true, cascadeDelete = false, onForeignDeleted = OnForeignDeleted.DELETE) 21 | private Document document; 22 | 23 | @ForeignKey(optional = true, cascadeDelete = false, onForeignDeleted = OnForeignDeleted.DELETE) 24 | private Page page; 25 | 26 | @Column 27 | private String text; 28 | 29 | public Envelope getEnvelope() { 30 | return envelope; 31 | } 32 | 33 | public void setEnvelope(Envelope envelope) { 34 | this.envelope = envelope; 35 | } 36 | 37 | public Document getDocument() { 38 | return document; 39 | } 40 | 41 | public void setDocument(Document document) { 42 | this.document = document; 43 | } 44 | 45 | public Page getPage() { 46 | return page; 47 | } 48 | 49 | public void setPage(Page page) { 50 | this.page = page; 51 | } 52 | 53 | public String getText() { 54 | return text; 55 | } 56 | 57 | public void setText(String text) { 58 | this.text = text; 59 | } 60 | 61 | public Long getId() { 62 | return id; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/envelopemodel/Page.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.envelopemodel; 2 | 3 | import java.util.Set; 4 | 5 | import org.springframework.data.annotation.Id; 6 | import org.springframework.data.relational.core.mapping.Column; 7 | import org.springframework.data.relational.core.mapping.Table; 8 | 9 | import net.lecousin.reactive.data.relational.annotations.ForeignKey; 10 | import net.lecousin.reactive.data.relational.annotations.ForeignTable; 11 | import net.lecousin.reactive.data.relational.annotations.ForeignKey.OnForeignDeleted; 12 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 13 | 14 | @Table("edm_page") 15 | public class Page { 16 | 17 | @Id @GeneratedValue 18 | private Long id; 19 | 20 | @ForeignKey(optional = false, cascadeDelete = false, onForeignDeleted = OnForeignDeleted.DELETE) 21 | private Document document; 22 | 23 | @Column 24 | private int pageIndex; 25 | 26 | @ForeignTable(joinKey = "page", optional = true) 27 | private Set notes; 28 | 29 | public Document getDocument() { 30 | return document; 31 | } 32 | 33 | public void setDocument(Document document) { 34 | this.document = document; 35 | } 36 | 37 | public int getPageIndex() { 38 | return pageIndex; 39 | } 40 | 41 | public void setPageIndex(int pageIndex) { 42 | this.pageIndex = pageIndex; 43 | } 44 | 45 | public Long getId() { 46 | return id; 47 | } 48 | 49 | public Set getNotes() { 50 | return notes; 51 | } 52 | 53 | public void setNotes(Set notes) { 54 | this.notes = notes; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/manytomanymodel/AllowEnhancer.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.manytomanymodel; 2 | 3 | public interface AllowEnhancer { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/manytomanymodel/Entity1.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.manytomanymodel; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.annotation.Id; 6 | import org.springframework.data.relational.core.mapping.Column; 7 | import org.springframework.data.relational.core.mapping.Table; 8 | 9 | import net.lecousin.reactive.data.relational.annotations.ForeignTable; 10 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 11 | import reactor.core.publisher.Flux; 12 | 13 | @Table 14 | public class Entity1 { 15 | 16 | @Id 17 | @GeneratedValue 18 | private Long id; 19 | 20 | @Column("value") 21 | private String value; 22 | 23 | @ForeignTable(joinKey = "entity1") 24 | private List links; 25 | 26 | public Long getId() { 27 | return id; 28 | } 29 | 30 | public void setId(Long id) { 31 | this.id = id; 32 | } 33 | 34 | public String getValue() { 35 | return value; 36 | } 37 | 38 | public void setValue(String value) { 39 | this.value = value; 40 | } 41 | 42 | public List getLinks() { 43 | return links; 44 | } 45 | 46 | public void setLinks(List links) { 47 | this.links = links; 48 | } 49 | 50 | public Flux lazyGetLinks() { 51 | return null; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/manytomanymodel/Entity1Repository.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.manytomanymodel; 2 | 3 | import net.lecousin.reactive.data.relational.query.SelectQuery; 4 | import net.lecousin.reactive.data.relational.query.criteria.Criteria; 5 | import net.lecousin.reactive.data.relational.repository.LcR2dbcRepository; 6 | import reactor.core.publisher.Flux; 7 | import reactor.core.publisher.Mono; 8 | 9 | public interface Entity1Repository extends LcR2dbcRepository { 10 | 11 | default Flux findByEntity1Value(String value) { 12 | return SelectQuery.from(Entity1.class, "e1").where(Criteria.property("e1", "value").is(value)).join("e1", "links", "link1").join("link1", "entity2", "e2").execute(getLcClient()); 13 | } 14 | 15 | default Flux findByEntity2Value(String value) { 16 | return SelectQuery.from(Entity1.class, "e1").where(Criteria.property("e2", "value").is(value)).join("e1", "links", "link1").join("link1", "entity2", "e2").execute(getLcClient()); 17 | } 18 | 19 | default Flux findByLinkedEntity1Value(String value) { 20 | return SelectQuery.from(Entity1.class, "e1").where(Criteria.property("e1bis", "value").is(value)).join("e1", "links", "link1").join("link1", "entity2", "e2").join("e2", "links", "link2").join("link2", "entity1", "e1bis").execute(getLcClient()); 21 | } 22 | 23 | default Mono countByLinkedEntity1Value(String value) { 24 | return SelectQuery.from(Entity1.class, "e1").where(Criteria.property("e1bis", "value").is(value)).join("e1", "links", "link1").join("link1", "entity2", "e2").join("e2", "links", "link2").join("link2", "entity1", "e1bis").executeCount(getLcClient()); 25 | } 26 | 27 | default Flux findWithLinks() { 28 | return SelectQuery.from(Entity1.class, "e1").join("e1", "links", "link1").join("link1", "entity2", "e2").execute(getLcClient()); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/manytomanymodel/Entity2.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.manytomanymodel; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.annotation.Id; 6 | import org.springframework.data.relational.core.mapping.Column; 7 | import org.springframework.data.relational.core.mapping.Table; 8 | 9 | import net.lecousin.reactive.data.relational.annotations.ForeignTable; 10 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 11 | import reactor.core.publisher.Flux; 12 | 13 | @Table 14 | public class Entity2 { 15 | 16 | @Id 17 | @GeneratedValue 18 | private Long id; 19 | 20 | @Column("value") 21 | private String value; 22 | 23 | @ForeignTable(joinKey = "entity2") 24 | private List links; 25 | 26 | public Long getId() { 27 | return id; 28 | } 29 | 30 | public void setId(Long id) { 31 | this.id = id; 32 | } 33 | 34 | public String getValue() { 35 | return value; 36 | } 37 | 38 | public void setValue(String value) { 39 | this.value = value; 40 | } 41 | 42 | public List getLinks() { 43 | return links; 44 | } 45 | 46 | public void setLinks(List links) { 47 | this.links = links; 48 | } 49 | 50 | public Flux lazyGetLinks() { 51 | return null; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/manytomanymodel/Entity3.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.manytomanymodel; 2 | 3 | import java.util.Set; 4 | 5 | import org.springframework.data.annotation.Id; 6 | import org.springframework.data.relational.core.mapping.Column; 7 | import org.springframework.data.relational.core.mapping.Table; 8 | 9 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 10 | import net.lecousin.reactive.data.relational.annotations.JoinTable; 11 | import reactor.core.publisher.Flux; 12 | 13 | @Table 14 | public class Entity3 { 15 | 16 | @Id 17 | @GeneratedValue 18 | private Long id; 19 | 20 | @Column("value") 21 | private String value; 22 | 23 | @JoinTable 24 | private Set links; 25 | 26 | public Long getId() { 27 | return id; 28 | } 29 | 30 | public void setId(Long id) { 31 | this.id = id; 32 | } 33 | 34 | public String getValue() { 35 | return value; 36 | } 37 | 38 | public void setValue(String value) { 39 | this.value = value; 40 | } 41 | 42 | public Set getLinks() { 43 | return links; 44 | } 45 | 46 | public void setLinks(Set links) { 47 | this.links = links; 48 | } 49 | 50 | public Flux lazyGetLinks() { 51 | return null; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/manytomanymodel/Entity3Repository.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.manytomanymodel; 2 | 3 | import net.lecousin.reactive.data.relational.query.SelectQuery; 4 | import net.lecousin.reactive.data.relational.query.criteria.Criteria; 5 | import net.lecousin.reactive.data.relational.repository.LcR2dbcRepository; 6 | import reactor.core.publisher.Flux; 7 | 8 | public interface Entity3Repository extends LcR2dbcRepository { 9 | 10 | default Flux findByEntity3Value(String value) { 11 | return SelectQuery.from(Entity3.class, "e1").where(Criteria.property("e1", "value").is(value)).join("e1", "links", "e2").execute(getLcClient()); 12 | } 13 | 14 | default Flux findByEntity4Value(String value) { 15 | return SelectQuery.from(Entity3.class, "e1").where(Criteria.property("e2", "value").is(value)).join("e1", "links", "e2").execute(getLcClient()); 16 | } 17 | 18 | default Flux findByLinkedEntity3Value(String value) { 19 | return SelectQuery.from(Entity3.class, "e1").where(Criteria.property("e1bis", "value").is(value)).join("e1", "links", "e2").join("e2", "links", "e1bis").execute(getLcClient()); 20 | } 21 | 22 | default Flux findWithLinks() { 23 | return SelectQuery.from(Entity3.class, "e1").join("e1", "links", "e2").execute(getLcClient()); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/manytomanymodel/Entity4.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.manytomanymodel; 2 | 3 | import java.util.Set; 4 | 5 | import org.springframework.data.annotation.Id; 6 | import org.springframework.data.relational.core.mapping.Column; 7 | import org.springframework.data.relational.core.mapping.Table; 8 | 9 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 10 | import net.lecousin.reactive.data.relational.annotations.JoinTable; 11 | import reactor.core.publisher.Flux; 12 | 13 | @Table 14 | public class Entity4 { 15 | 16 | @Id 17 | @GeneratedValue 18 | private Long id; 19 | 20 | @Column("value") 21 | private String value; 22 | 23 | @JoinTable(columnName = "entity3") 24 | private Set links; 25 | 26 | public Long getId() { 27 | return id; 28 | } 29 | 30 | public void setId(Long id) { 31 | this.id = id; 32 | } 33 | 34 | public String getValue() { 35 | return value; 36 | } 37 | 38 | public void setValue(String value) { 39 | this.value = value; 40 | } 41 | 42 | public Set getLinks() { 43 | return links; 44 | } 45 | 46 | public void setLinks(Set links) { 47 | this.links = links; 48 | } 49 | 50 | public Flux lazyGetLinks() { 51 | return null; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/manytomanymodel/JoinEntity.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.manytomanymodel; 2 | 3 | import org.springframework.data.relational.core.mapping.Table; 4 | 5 | import net.lecousin.reactive.data.relational.annotations.ForeignKey; 6 | 7 | @Table 8 | public class JoinEntity { 9 | 10 | @ForeignKey(optional = false) 11 | private Entity1 entity1; 12 | 13 | @ForeignKey(optional = false) 14 | private Entity2 entity2; 15 | 16 | public Entity1 getEntity1() { 17 | return entity1; 18 | } 19 | 20 | public void setEntity1(Entity1 entity1) { 21 | this.entity1 = entity1; 22 | } 23 | 24 | public Entity2 getEntity2() { 25 | return entity2; 26 | } 27 | 28 | public void setEntity2(Entity2 entity2) { 29 | this.entity2 = entity2; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/manytomanymodel/package-info.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.manytomanymodel; -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/model1/AllowEnhancer.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.model1; 2 | 3 | public interface AllowEnhancer { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/model1/CompanyRepository.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.model1; 2 | 3 | import net.lecousin.reactive.data.relational.query.SelectQuery; 4 | import net.lecousin.reactive.data.relational.repository.LcR2dbcRepository; 5 | import reactor.core.publisher.Flux; 6 | import reactor.core.publisher.Mono; 7 | 8 | public interface CompanyRepository extends LcR2dbcRepository { 9 | 10 | Mono findByName(String name); 11 | 12 | default Flux findAllWithJoins() { 13 | return SelectQuery.from(Company.class, "company") 14 | .join("company", "owner", "companyOwner") 15 | .join("companyOwner", "address", "companyOwnerAddress") 16 | .join("company", "employees", "employee") 17 | .join("employee", "person", "employeePerson") 18 | .join("employeePerson", "address", "employeeAddress") 19 | .join("company", "sites", "site") 20 | .join("site", "address", "siteAddress") 21 | .join("company", "providers", "provider") 22 | .join("provider", "person", "providerPerson") 23 | .join("providerPerson", "address", "providerPersonAddress") 24 | .join("provider", "provider", "providerCompany") 25 | .execute(getLcClient()); 26 | } 27 | 28 | default Flux findAllWithJoins(int start, int nb) { 29 | return SelectQuery.from(Company.class, "company") 30 | .join("company", "owner", "companyOwner") 31 | .join("companyOwner", "address", "companyOwnerAddress") 32 | .join("company", "employees", "employee") 33 | .join("employee", "person", "employeePerson") 34 | .join("employeePerson", "address", "employeeAddress") 35 | .join("company", "sites", "site") 36 | .join("site", "address", "siteAddress") 37 | .join("company", "providers", "provider") 38 | .join("provider", "person", "providerPerson") 39 | .join("providerPerson", "address", "providerPersonAddress") 40 | .join("provider", "provider", "providerCompany") 41 | .limit(start, nb) 42 | .execute(getLcClient()); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/model1/Employee.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.model1; 2 | 3 | import org.springframework.data.relational.core.mapping.Table; 4 | 5 | import net.lecousin.reactive.data.relational.annotations.CompositeId; 6 | import net.lecousin.reactive.data.relational.annotations.ForeignKey; 7 | import net.lecousin.reactive.data.relational.annotations.ForeignKey.OnForeignDeleted; 8 | 9 | @Table 10 | @CompositeId(indexName = "employee_pk", properties = { "company", "person" }) 11 | public class Employee { 12 | 13 | @ForeignKey(optional = false, onForeignDeleted = OnForeignDeleted.DELETE) 14 | private Company company; 15 | 16 | @ForeignKey(optional = false, onForeignDeleted = OnForeignDeleted.DELETE) 17 | private Person person; 18 | 19 | public Company getCompany() { 20 | return company; 21 | } 22 | 23 | public void setCompany(Company company) { 24 | this.company = company; 25 | } 26 | 27 | public Person getPerson() { 28 | return person; 29 | } 30 | 31 | public void setPerson(Person person) { 32 | this.person = person; 33 | } 34 | 35 | public boolean entityLoaded() { 36 | return false; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/model1/PersonRepository.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.model1; 2 | 3 | import net.lecousin.reactive.data.relational.repository.LcR2dbcRepository; 4 | import reactor.core.publisher.Flux; 5 | 6 | public interface PersonRepository extends LcR2dbcRepository { 7 | 8 | Flux findByFirstName(String firstName); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/model1/PostalAddress.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.model1; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.relational.core.mapping.Column; 5 | import org.springframework.data.relational.core.mapping.Table; 6 | 7 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 8 | 9 | @Table 10 | public class PostalAddress { 11 | 12 | @Id @GeneratedValue 13 | private Long id; 14 | 15 | @Column 16 | private String address; 17 | 18 | @Column 19 | private int postalCode; 20 | 21 | @Column 22 | private String city; 23 | 24 | @Column 25 | private String country; 26 | 27 | public Long getId() { 28 | return id; 29 | } 30 | 31 | public void setId(Long id) { 32 | this.id = id; 33 | } 34 | 35 | public String getAddress() { 36 | return address; 37 | } 38 | 39 | public void setAddress(String address) { 40 | this.address = address; 41 | } 42 | 43 | public int getPostalCode() { 44 | return postalCode; 45 | } 46 | 47 | public void setPostalCode(int postalCode) { 48 | this.postalCode = postalCode; 49 | } 50 | 51 | public String getCity() { 52 | return city; 53 | } 54 | 55 | public void setCity(String city) { 56 | this.city = city; 57 | } 58 | 59 | public String getCountry() { 60 | return country; 61 | } 62 | 63 | public void setCountry(String country) { 64 | this.country = country; 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/model1/Site.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.model1; 2 | 3 | import org.springframework.data.relational.core.mapping.Column; 4 | import org.springframework.data.relational.core.mapping.Table; 5 | 6 | import net.lecousin.reactive.data.relational.annotations.CompositeId; 7 | import net.lecousin.reactive.data.relational.annotations.ForeignKey; 8 | import net.lecousin.reactive.data.relational.annotations.ForeignKey.OnForeignDeleted; 9 | 10 | @Table 11 | @CompositeId(indexName = "siteId", properties = { "company", "address" }) 12 | public class Site { 13 | 14 | @ForeignKey(optional = false, onForeignDeleted = OnForeignDeleted.DELETE) 15 | private Company company; 16 | 17 | @ForeignKey(optional = false, onForeignDeleted = OnForeignDeleted.DELETE, cascadeDelete = true) 18 | private PostalAddress address; 19 | 20 | @Column 21 | private String name; 22 | 23 | public Company getCompany() { 24 | return company; 25 | } 26 | 27 | public void setCompany(Company company) { 28 | this.company = company; 29 | } 30 | 31 | public PostalAddress getAddress() { 32 | return address; 33 | } 34 | 35 | public void setAddress(PostalAddress address) { 36 | this.address = address; 37 | } 38 | 39 | public String getName() { 40 | return name; 41 | } 42 | 43 | public void setName(String name) { 44 | this.name = name; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/model1/User.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.model1; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.annotation.Version; 5 | import org.springframework.data.relational.core.mapping.Column; 6 | import org.springframework.data.relational.core.mapping.Table; 7 | 8 | import net.lecousin.reactive.data.relational.annotations.ForeignKey; 9 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 10 | 11 | @Table("usr") 12 | public class User { 13 | 14 | @Id @GeneratedValue 15 | private Long id; 16 | 17 | @Version 18 | private Long version; 19 | 20 | @Column 21 | private String username; 22 | 23 | @ForeignKey(optional = true, cascadeDelete = true) 24 | private Person person; 25 | 26 | public Long getId() { 27 | return id; 28 | } 29 | 30 | public void setId(Long id) { 31 | this.id = id; 32 | } 33 | 34 | public Long getVersion() { 35 | return version; 36 | } 37 | 38 | public void setVersion(Long version) { 39 | this.version = version; 40 | } 41 | 42 | public String getUsername() { 43 | return username; 44 | } 45 | 46 | public void setUsername(String username) { 47 | this.username = username; 48 | } 49 | 50 | public Person getPerson() { 51 | return person; 52 | } 53 | 54 | public void setPerson(Person person) { 55 | this.person = person; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/model1/package-info.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.model1; -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/multipleconnections/db1/Config1.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.multipleconnections.db1; 2 | 3 | import org.springframework.beans.factory.annotation.Qualifier; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories; 7 | 8 | import io.r2dbc.spi.ConnectionFactories; 9 | import io.r2dbc.spi.ConnectionFactory; 10 | import net.lecousin.reactive.data.relational.configuration.LcR2dbcEntityOperationsBuilder; 11 | import net.lecousin.reactive.data.relational.repository.LcR2dbcEntityTemplate; 12 | import net.lecousin.reactive.data.relational.repository.LcR2dbcRepositoryFactoryBean; 13 | 14 | @Configuration 15 | @EnableR2dbcRepositories(repositoryFactoryBeanClass = LcR2dbcRepositoryFactoryBean.class, basePackages = "net.lecousin.reactive.data.relational.test.multipleconnections.db1", entityOperationsRef = "db1Operations") 16 | public class Config1 extends LcR2dbcEntityOperationsBuilder { 17 | 18 | @Bean 19 | @Qualifier("db1DatabaseConnectionFactory") 20 | public ConnectionFactory db1DatabaseConnectionFactory(@Qualifier("db1Url") String databaseUrl) { 21 | return ConnectionFactories.get(databaseUrl); 22 | } 23 | 24 | @Bean 25 | @Qualifier("db1Operations") 26 | public LcR2dbcEntityTemplate db1Operations(@Qualifier("db1DatabaseConnectionFactory") ConnectionFactory connectionFactory) { 27 | return buildEntityOperations(connectionFactory); 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/multipleconnections/db1/MultipleDbEntity1.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.multipleconnections.db1; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.relational.core.mapping.Column; 5 | import org.springframework.data.relational.core.mapping.Table; 6 | 7 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 8 | 9 | @Table 10 | public class MultipleDbEntity1 { 11 | 12 | @Id @GeneratedValue 13 | private Long id; 14 | 15 | @Column("value") 16 | private String value; 17 | 18 | public Long getId() { 19 | return id; 20 | } 21 | 22 | public void setId(Long id) { 23 | this.id = id; 24 | } 25 | 26 | public String getValue() { 27 | return value; 28 | } 29 | 30 | public void setValue(String value) { 31 | this.value = value; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/multipleconnections/db1/MyRepository1.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.multipleconnections.db1; 2 | 3 | import net.lecousin.reactive.data.relational.repository.LcR2dbcRepository; 4 | 5 | public interface MyRepository1 extends LcR2dbcRepository { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/multipleconnections/db2/Config2.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.multipleconnections.db2; 2 | 3 | import org.springframework.beans.factory.annotation.Qualifier; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories; 7 | 8 | import io.r2dbc.spi.ConnectionFactories; 9 | import io.r2dbc.spi.ConnectionFactory; 10 | import net.lecousin.reactive.data.relational.configuration.LcR2dbcEntityOperationsBuilder; 11 | import net.lecousin.reactive.data.relational.repository.LcR2dbcEntityTemplate; 12 | import net.lecousin.reactive.data.relational.repository.LcR2dbcRepositoryFactoryBean; 13 | 14 | @Configuration 15 | @EnableR2dbcRepositories(repositoryFactoryBeanClass = LcR2dbcRepositoryFactoryBean.class, basePackages = "net.lecousin.reactive.data.relational.test.multipleconnections.db2", entityOperationsRef = "db2Operations") 16 | public class Config2 extends LcR2dbcEntityOperationsBuilder { 17 | 18 | @Bean 19 | @Qualifier("db2DatabaseConnectionFactory") 20 | public ConnectionFactory db2DatabaseConnectionFactory(@Qualifier("db2Url") String databaseUrl) { 21 | return ConnectionFactories.get(databaseUrl); 22 | } 23 | 24 | @Bean 25 | @Qualifier("db2Operations") 26 | public LcR2dbcEntityTemplate db2Operations(@Qualifier("db2DatabaseConnectionFactory") ConnectionFactory connectionFactory) { 27 | return buildEntityOperations(connectionFactory); 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/multipleconnections/db2/MultipleDbEntity2.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.multipleconnections.db2; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.relational.core.mapping.Column; 5 | import org.springframework.data.relational.core.mapping.Table; 6 | 7 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 8 | 9 | @Table 10 | public class MultipleDbEntity2 { 11 | 12 | @Id @GeneratedValue 13 | private Long id; 14 | 15 | @Column("value") 16 | private String value; 17 | 18 | public Long getId() { 19 | return id; 20 | } 21 | 22 | public void setId(Long id) { 23 | this.id = id; 24 | } 25 | 26 | public String getValue() { 27 | return value; 28 | } 29 | 30 | public void setValue(String value) { 31 | this.value = value; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/multipleconnections/db2/MyRepository2.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.multipleconnections.db2; 2 | 3 | import net.lecousin.reactive.data.relational.repository.LcR2dbcRepository; 4 | 5 | public interface MyRepository2 extends LcR2dbcRepository { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/onetomanymodel/AllowEnhancer.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.onetomanymodel; 2 | 3 | public interface AllowEnhancer { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/onetomanymodel/RootEntity.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.onetomanymodel; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.annotation.Id; 6 | import org.springframework.data.relational.core.mapping.Column; 7 | import org.springframework.data.relational.core.mapping.Table; 8 | 9 | import net.lecousin.reactive.data.relational.annotations.ForeignTable; 10 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 11 | import reactor.core.publisher.Flux; 12 | 13 | @Table 14 | public class RootEntity { 15 | 16 | @Id 17 | @GeneratedValue 18 | private Long id; 19 | 20 | @Column("value") 21 | private String value; 22 | 23 | @ForeignTable(joinKey = "parent") 24 | private List list; 25 | 26 | @ForeignTable(joinKey = "parent") 27 | private List list2; 28 | 29 | @ForeignTable(joinKey = "parent") 30 | private List list3; 31 | 32 | public Long getId() { 33 | return id; 34 | } 35 | 36 | public void setId(Long id) { 37 | this.id = id; 38 | } 39 | 40 | public String getValue() { 41 | return value; 42 | } 43 | 44 | public void setValue(String value) { 45 | this.value = value; 46 | } 47 | 48 | public List getList() { 49 | return list; 50 | } 51 | 52 | public void setList(List list) { 53 | this.list = list; 54 | } 55 | 56 | public Flux lazyGetList() { 57 | return null; 58 | } 59 | 60 | public List getList2() { 61 | return list2; 62 | } 63 | 64 | public void setList2(List list2) { 65 | this.list2 = list2; 66 | } 67 | 68 | public Flux lazyGetList2() { 69 | return null; 70 | } 71 | 72 | public List getList3() { 73 | return list3; 74 | } 75 | 76 | public void setList3(List list3) { 77 | this.list3 = list3; 78 | } 79 | 80 | public Flux lazyGetList3() { 81 | return null; 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/onetomanymodel/RootEntityWithConstructor.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.onetomanymodel; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.annotation.Id; 6 | import org.springframework.data.relational.core.mapping.Column; 7 | import org.springframework.data.relational.core.mapping.Table; 8 | 9 | import net.lecousin.reactive.data.relational.annotations.ForeignTable; 10 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 11 | import reactor.core.publisher.Flux; 12 | 13 | @Table 14 | public class RootEntityWithConstructor { 15 | 16 | @Id 17 | @GeneratedValue 18 | private Long id; 19 | 20 | @Column("value") 21 | private String value; 22 | 23 | @ForeignTable(joinKey = "parent") 24 | private List list; 25 | 26 | public RootEntityWithConstructor(Long id, String value, List list) { 27 | this.id = id; 28 | this.value = value; 29 | this.list = list; 30 | } 31 | 32 | public Long getId() { 33 | return id; 34 | } 35 | 36 | public void setId(Long id) { 37 | this.id = id; 38 | } 39 | 40 | public String getValue() { 41 | return value; 42 | } 43 | 44 | public void setValue(String value) { 45 | this.value = value; 46 | } 47 | 48 | public List getList() { 49 | return list; 50 | } 51 | 52 | public void setList(List list) { 53 | this.list = list; 54 | } 55 | 56 | public Flux lazyGetList() { 57 | return null; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/onetomanymodel/SubEntity.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.onetomanymodel; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.relational.core.mapping.Column; 5 | import org.springframework.data.relational.core.mapping.Table; 6 | 7 | import net.lecousin.reactive.data.relational.annotations.ForeignKey; 8 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 9 | 10 | @Table 11 | public class SubEntity { 12 | 13 | @Id 14 | @GeneratedValue 15 | private Long id; 16 | 17 | @Column 18 | private String subValue; 19 | 20 | @ForeignKey(optional = false) 21 | private RootEntity parent; 22 | 23 | public Long getId() { 24 | return id; 25 | } 26 | 27 | public void setId(Long id) { 28 | this.id = id; 29 | } 30 | 31 | public String getSubValue() { 32 | return subValue; 33 | } 34 | 35 | public void setSubValue(String subValue) { 36 | this.subValue = subValue; 37 | } 38 | 39 | public RootEntity getParent() { 40 | return parent; 41 | } 42 | 43 | public void setParent(RootEntity parent) { 44 | this.parent = parent; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/onetomanymodel/SubEntity2.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.onetomanymodel; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.relational.core.mapping.Column; 5 | import org.springframework.data.relational.core.mapping.Table; 6 | 7 | import net.lecousin.reactive.data.relational.annotations.ForeignKey; 8 | import net.lecousin.reactive.data.relational.annotations.ForeignKey.OnForeignDeleted; 9 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 10 | 11 | @Table 12 | public class SubEntity2 { 13 | 14 | @Id 15 | @GeneratedValue 16 | private Long id; 17 | 18 | @Column 19 | private String subValue; 20 | 21 | @ForeignKey(optional = true, onForeignDeleted = OnForeignDeleted.DELETE) 22 | private RootEntity parent; 23 | 24 | public SubEntity2(String subValue) { 25 | this.subValue = subValue; 26 | } 27 | 28 | public Long getId() { 29 | return id; 30 | } 31 | 32 | public void setId(Long id) { 33 | this.id = id; 34 | } 35 | 36 | public String getSubValue() { 37 | return subValue; 38 | } 39 | 40 | public RootEntity getParent() { 41 | return parent; 42 | } 43 | 44 | public void setParent(RootEntity parent) { 45 | this.parent = parent; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/onetomanymodel/SubEntity3.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.onetomanymodel; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.annotation.Version; 5 | import org.springframework.data.relational.core.mapping.Column; 6 | import org.springframework.data.relational.core.mapping.Table; 7 | 8 | import net.lecousin.reactive.data.relational.annotations.ForeignKey; 9 | import net.lecousin.reactive.data.relational.annotations.ForeignKey.OnForeignDeleted; 10 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 11 | 12 | @Table 13 | public class SubEntity3 { 14 | 15 | @Id 16 | @GeneratedValue 17 | private Long id; 18 | 19 | @Version 20 | private Long version; 21 | 22 | @Column 23 | private String subValue; 24 | 25 | @ForeignKey(optional = true, onForeignDeleted = OnForeignDeleted.SET_TO_NULL) 26 | private RootEntity parent; 27 | 28 | public Long getId() { 29 | return id; 30 | } 31 | 32 | public void setId(Long id) { 33 | this.id = id; 34 | } 35 | 36 | public Long getVersion() { 37 | return version; 38 | } 39 | 40 | public void setVersion(Long version) { 41 | this.version = version; 42 | } 43 | 44 | public String getSubValue() { 45 | return subValue; 46 | } 47 | 48 | public void setSubValue(String subValue) { 49 | this.subValue = subValue; 50 | } 51 | 52 | public RootEntity getParent() { 53 | return parent; 54 | } 55 | 56 | public void setParent(RootEntity parent) { 57 | this.parent = parent; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/onetomanymodel/SubEntityWithConstructor.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.onetomanymodel; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.relational.core.mapping.Column; 5 | import org.springframework.data.relational.core.mapping.Table; 6 | 7 | import net.lecousin.reactive.data.relational.annotations.ForeignKey; 8 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 9 | 10 | @Table 11 | public class SubEntityWithConstructor { 12 | 13 | @Id 14 | @GeneratedValue 15 | private Long id; 16 | 17 | @Column 18 | private String subValue; 19 | 20 | @ForeignKey(optional = false) 21 | private RootEntityWithConstructor parent; 22 | 23 | public SubEntityWithConstructor(Long id, String subValue, RootEntityWithConstructor parent) { 24 | this.id = id; 25 | this.subValue = subValue; 26 | this.parent = parent; 27 | } 28 | 29 | public Long getId() { 30 | return id; 31 | } 32 | 33 | public void setId(Long id) { 34 | this.id = id; 35 | } 36 | 37 | public String getSubValue() { 38 | return subValue; 39 | } 40 | 41 | public void setSubValue(String subValue) { 42 | this.subValue = subValue; 43 | } 44 | 45 | public RootEntityWithConstructor getParent() { 46 | return parent; 47 | } 48 | 49 | public void setParent(RootEntityWithConstructor parent) { 50 | this.parent = parent; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/onetomanymodel/package-info.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.onetomanymodel; -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/onetoonemodel/AllowEnhancer.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.onetoonemodel; 2 | 3 | public interface AllowEnhancer { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/onetoonemodel/MyEntity1.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.onetoonemodel; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.relational.core.mapping.Column; 5 | import org.springframework.data.relational.core.mapping.Table; 6 | 7 | import net.lecousin.reactive.data.relational.annotations.ForeignTable; 8 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 9 | import reactor.core.publisher.Mono; 10 | 11 | @Table 12 | public class MyEntity1 { 13 | 14 | @Id 15 | @GeneratedValue 16 | private Long id; 17 | 18 | @Column("value") 19 | private String value; 20 | 21 | @ForeignTable(joinKey = "parent", optional = true) 22 | private MySubEntity1 subEntity; 23 | 24 | public Long getId() { 25 | return id; 26 | } 27 | 28 | public void setId(Long id) { 29 | this.id = id; 30 | } 31 | 32 | public String getValue() { 33 | return value; 34 | } 35 | 36 | public void setValue(String value) { 37 | this.value = value; 38 | } 39 | 40 | public MySubEntity1 getSubEntity() { 41 | return subEntity; 42 | } 43 | 44 | public void setSubEntity(MySubEntity1 subEntity) { 45 | this.subEntity = subEntity; 46 | } 47 | 48 | public Mono lazyGetSubEntity() { 49 | return null; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/onetoonemodel/MyEntity1Repository.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.onetoonemodel; 2 | 3 | import net.lecousin.reactive.data.relational.query.SelectQuery; 4 | import net.lecousin.reactive.data.relational.query.criteria.Criteria; 5 | import net.lecousin.reactive.data.relational.repository.LcR2dbcRepository; 6 | import reactor.core.publisher.Flux; 7 | 8 | public interface MyEntity1Repository extends LcR2dbcRepository { 9 | 10 | default Flux findByValue(String value) { 11 | return SelectQuery.from(MyEntity1.class, "entity").where(Criteria.property("entity", "value").is(value)).join("entity", "subEntity", "sub").execute(getLcClient()); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/onetoonemodel/MyEntity1WithConstructor.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.onetoonemodel; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.relational.core.mapping.Column; 5 | import org.springframework.data.relational.core.mapping.Table; 6 | 7 | import net.lecousin.reactive.data.relational.annotations.ForeignTable; 8 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 9 | import reactor.core.publisher.Mono; 10 | 11 | @Table 12 | public class MyEntity1WithConstructor { 13 | 14 | @Id 15 | @GeneratedValue 16 | private Long id; 17 | 18 | @Column("value") 19 | private String value; 20 | 21 | @ForeignTable(joinKey = "parent", optional = true) 22 | private MySubEntity1WithConstructor subEntity; 23 | 24 | public MyEntity1WithConstructor(Long id, String value, MySubEntity1WithConstructor subEntity) { 25 | this.id = id; 26 | this.value = value; 27 | this.subEntity = subEntity; 28 | } 29 | 30 | public Long getId() { 31 | return id; 32 | } 33 | 34 | public void setId(Long id) { 35 | this.id = id; 36 | } 37 | 38 | public String getValue() { 39 | return value; 40 | } 41 | 42 | public void setValue(String value) { 43 | this.value = value; 44 | } 45 | 46 | public MySubEntity1WithConstructor getSubEntity() { 47 | return subEntity; 48 | } 49 | 50 | public void setSubEntity(MySubEntity1WithConstructor subEntity) { 51 | this.subEntity = subEntity; 52 | } 53 | 54 | public Mono lazyGetSubEntity() { 55 | return null; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/onetoonemodel/MyEntity1WithConstructorRepository.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.onetoonemodel; 2 | 3 | import net.lecousin.reactive.data.relational.query.SelectQuery; 4 | import net.lecousin.reactive.data.relational.query.criteria.Criteria; 5 | import net.lecousin.reactive.data.relational.repository.LcR2dbcRepository; 6 | import reactor.core.publisher.Flux; 7 | 8 | public interface MyEntity1WithConstructorRepository extends LcR2dbcRepository { 9 | 10 | default Flux findByValue(String value) { 11 | return SelectQuery.from(MyEntity1WithConstructor.class, "entity").where(Criteria.property("entity", "value").is(value)).join("entity", "subEntity", "sub").execute(getLcClient()); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/onetoonemodel/MyEntity2.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.onetoonemodel; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.relational.core.mapping.Column; 5 | import org.springframework.data.relational.core.mapping.Table; 6 | 7 | import net.lecousin.reactive.data.relational.annotations.ForeignKey; 8 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 9 | import reactor.core.publisher.Mono; 10 | 11 | @Table 12 | public class MyEntity2 { 13 | 14 | @Id 15 | @GeneratedValue 16 | private Long id; 17 | 18 | @Column("value") 19 | private String value; 20 | 21 | @ForeignKey(optional = true) 22 | private MySubEntity2 subEntity; 23 | 24 | public Long getId() { 25 | return id; 26 | } 27 | 28 | public void setId(Long id) { 29 | this.id = id; 30 | } 31 | 32 | public String getValue() { 33 | return value; 34 | } 35 | 36 | public void setValue(String value) { 37 | this.value = value; 38 | } 39 | 40 | public MySubEntity2 getSubEntity() { 41 | return subEntity; 42 | } 43 | 44 | public void setSubEntity(MySubEntity2 subEntity) { 45 | this.subEntity = subEntity; 46 | } 47 | 48 | public Mono lazyGetSubEntity() { 49 | return null; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/onetoonemodel/MyEntity2Repository.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.onetoonemodel; 2 | 3 | import net.lecousin.reactive.data.relational.repository.LcR2dbcRepository; 4 | 5 | public interface MyEntity2Repository extends LcR2dbcRepository { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/onetoonemodel/MyEntity3.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.onetoonemodel; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.relational.core.mapping.Column; 5 | import org.springframework.data.relational.core.mapping.Table; 6 | 7 | import net.lecousin.reactive.data.relational.annotations.ForeignTable; 8 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 9 | import reactor.core.publisher.Mono; 10 | 11 | @Table 12 | public class MyEntity3 { 13 | 14 | @Id 15 | @GeneratedValue 16 | private Long id; 17 | 18 | @Column("value") 19 | private String value; 20 | 21 | @ForeignTable(joinKey = "parent", optional = true) 22 | private MySubEntity3 subEntity; 23 | 24 | public Long getId() { 25 | return id; 26 | } 27 | 28 | public void setId(Long id) { 29 | this.id = id; 30 | } 31 | 32 | public String getValue() { 33 | return value; 34 | } 35 | 36 | public void setValue(String value) { 37 | this.value = value; 38 | } 39 | 40 | public MySubEntity3 getSubEntity() { 41 | return subEntity; 42 | } 43 | 44 | public void setSubEntity(MySubEntity3 subEntity) { 45 | this.subEntity = subEntity; 46 | } 47 | 48 | public Mono lazyGetSubEntity() { 49 | return null; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/onetoonemodel/MyEntity3Repository.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.onetoonemodel; 2 | 3 | import net.lecousin.reactive.data.relational.repository.LcR2dbcRepository; 4 | 5 | public interface MyEntity3Repository extends LcR2dbcRepository { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/onetoonemodel/MyEntity4.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.onetoonemodel; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.relational.core.mapping.Column; 5 | import org.springframework.data.relational.core.mapping.Table; 6 | 7 | import net.lecousin.reactive.data.relational.annotations.ForeignTable; 8 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 9 | import reactor.core.publisher.Mono; 10 | 11 | @Table 12 | public class MyEntity4 { 13 | 14 | @Id 15 | @GeneratedValue 16 | private Long id; 17 | 18 | @Column("value") 19 | private String value; 20 | 21 | @ForeignTable(joinKey = "parent", optional = false) 22 | private MySubEntity4 subEntity; 23 | 24 | public Long getId() { 25 | return id; 26 | } 27 | 28 | public void setId(Long id) { 29 | this.id = id; 30 | } 31 | 32 | public String getValue() { 33 | return value; 34 | } 35 | 36 | public void setValue(String value) { 37 | this.value = value; 38 | } 39 | 40 | public MySubEntity4 getSubEntity() { 41 | return subEntity; 42 | } 43 | 44 | public void setSubEntity(MySubEntity4 subEntity) { 45 | this.subEntity = subEntity; 46 | } 47 | 48 | public Mono lazyGetSubEntity() { 49 | return null; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/onetoonemodel/MyEntity4Repository.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.onetoonemodel; 2 | 3 | import net.lecousin.reactive.data.relational.query.SelectQuery; 4 | import net.lecousin.reactive.data.relational.repository.LcR2dbcRepository; 5 | import reactor.core.publisher.Flux; 6 | 7 | public interface MyEntity4Repository extends LcR2dbcRepository { 8 | 9 | default Flux findAllWithSubEntities() { 10 | return SelectQuery.from(MyEntity4.class, "e").join("e", "subEntity", "s").join("s", "entity1", "e1").execute(getLcClient()); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/onetoonemodel/MyEntity5.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.onetoonemodel; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.relational.core.mapping.Column; 5 | import org.springframework.data.relational.core.mapping.Table; 6 | 7 | import net.lecousin.reactive.data.relational.annotations.ForeignTable; 8 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 9 | 10 | @Table 11 | public class MyEntity5 { 12 | 13 | @Id 14 | @GeneratedValue 15 | private Long id; 16 | 17 | @Column("value") 18 | private String value; 19 | 20 | @ForeignTable(joinKey = "parent", optional = false) 21 | private MySubEntity5 subEntity; 22 | 23 | public Long getId() { 24 | return id; 25 | } 26 | 27 | public void setId(Long id) { 28 | this.id = id; 29 | } 30 | 31 | public String getValue() { 32 | return value; 33 | } 34 | 35 | public void setValue(String value) { 36 | this.value = value; 37 | } 38 | 39 | public MySubEntity5 getSubEntity() { 40 | return subEntity; 41 | } 42 | 43 | public void setSubEntity(MySubEntity5 subEntity) { 44 | this.subEntity = subEntity; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/onetoonemodel/MyEntity6.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.onetoonemodel; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.relational.core.mapping.Column; 5 | import org.springframework.data.relational.core.mapping.Table; 6 | 7 | import net.lecousin.reactive.data.relational.annotations.ForeignTable; 8 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 9 | 10 | @Table 11 | public class MyEntity6 { 12 | 13 | @Id 14 | @GeneratedValue 15 | private Long id; 16 | 17 | @Column("value") 18 | private String value; 19 | 20 | @ForeignTable(joinKey = "parent", optional = false) 21 | private MySubEntity6 subEntity; 22 | 23 | public Long getId() { 24 | return id; 25 | } 26 | 27 | public void setId(Long id) { 28 | this.id = id; 29 | } 30 | 31 | public String getValue() { 32 | return value; 33 | } 34 | 35 | public void setValue(String value) { 36 | this.value = value; 37 | } 38 | 39 | public MySubEntity6 getSubEntity() { 40 | return subEntity; 41 | } 42 | 43 | public void setSubEntity(MySubEntity6 subEntity) { 44 | this.subEntity = subEntity; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/onetoonemodel/MySubEntity1.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.onetoonemodel; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.relational.core.mapping.Column; 5 | import org.springframework.data.relational.core.mapping.Table; 6 | 7 | import net.lecousin.reactive.data.relational.annotations.ForeignKey; 8 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 9 | 10 | @Table 11 | public class MySubEntity1 { 12 | 13 | @Id 14 | @GeneratedValue 15 | private Long id; 16 | 17 | @Column 18 | private String subValue; 19 | 20 | @ForeignKey(optional = false) 21 | private MyEntity1 parent; 22 | 23 | public Long getId() { 24 | return id; 25 | } 26 | 27 | public void setId(Long id) { 28 | this.id = id; 29 | } 30 | 31 | public String getSubValue() { 32 | return subValue; 33 | } 34 | 35 | public void setSubValue(String subValue) { 36 | this.subValue = subValue; 37 | } 38 | 39 | public MyEntity1 getParent() { 40 | return parent; 41 | } 42 | 43 | public void setParent(MyEntity1 parent) { 44 | this.parent = parent; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/onetoonemodel/MySubEntity1Repository.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.onetoonemodel; 2 | 3 | import net.lecousin.reactive.data.relational.repository.LcR2dbcRepository; 4 | 5 | public interface MySubEntity1Repository extends LcR2dbcRepository { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/onetoonemodel/MySubEntity1WithConstructor.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.onetoonemodel; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.relational.core.mapping.Column; 5 | import org.springframework.data.relational.core.mapping.Table; 6 | 7 | import net.lecousin.reactive.data.relational.annotations.ForeignKey; 8 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 9 | 10 | @Table 11 | public class MySubEntity1WithConstructor { 12 | 13 | @Id 14 | @GeneratedValue 15 | private Long id; 16 | 17 | @Column 18 | private String subValue; 19 | 20 | @ForeignKey(optional = false) 21 | private MyEntity1WithConstructor parent; 22 | 23 | public MySubEntity1WithConstructor(Long id, String subValue, MyEntity1WithConstructor parent) { 24 | this.id = id; 25 | this.subValue = subValue; 26 | this.parent = parent; 27 | } 28 | 29 | public Long getId() { 30 | return id; 31 | } 32 | 33 | public void setId(Long id) { 34 | this.id = id; 35 | } 36 | 37 | public String getSubValue() { 38 | return subValue; 39 | } 40 | 41 | public void setSubValue(String subValue) { 42 | this.subValue = subValue; 43 | } 44 | 45 | public MyEntity1WithConstructor getParent() { 46 | return parent; 47 | } 48 | 49 | public void setParent(MyEntity1WithConstructor parent) { 50 | this.parent = parent; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/onetoonemodel/MySubEntity2.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.onetoonemodel; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.relational.core.mapping.Column; 5 | import org.springframework.data.relational.core.mapping.Table; 6 | 7 | import net.lecousin.reactive.data.relational.annotations.ForeignTable; 8 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 9 | import reactor.core.publisher.Mono; 10 | 11 | @Table 12 | public class MySubEntity2 { 13 | 14 | @Id 15 | @GeneratedValue 16 | private Long id; 17 | 18 | @Column 19 | private String subValue; 20 | 21 | @ForeignTable(joinKey = "subEntity", optional = false) 22 | private MyEntity2 parent; 23 | 24 | public Long getId() { 25 | return id; 26 | } 27 | 28 | public void setId(Long id) { 29 | this.id = id; 30 | } 31 | 32 | public String getSubValue() { 33 | return subValue; 34 | } 35 | 36 | public void setSubValue(String subValue) { 37 | this.subValue = subValue; 38 | } 39 | 40 | public MyEntity2 getParent() { 41 | return parent; 42 | } 43 | 44 | public void setParent(MyEntity2 parent) { 45 | this.parent = parent; 46 | } 47 | 48 | public boolean entityLoaded() { 49 | return true; 50 | } 51 | 52 | public Mono loadEntity() { 53 | return null; 54 | } 55 | 56 | public Mono lazyGetSubValue() { 57 | return null; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/onetoonemodel/MySubEntity3.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.onetoonemodel; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.relational.core.mapping.Column; 5 | import org.springframework.data.relational.core.mapping.Table; 6 | 7 | import net.lecousin.reactive.data.relational.annotations.ForeignKey; 8 | import net.lecousin.reactive.data.relational.annotations.ForeignKey.OnForeignDeleted; 9 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 10 | 11 | @Table 12 | public class MySubEntity3 { 13 | 14 | @Id 15 | @GeneratedValue 16 | private Long id; 17 | 18 | @Column 19 | private String subValue; 20 | 21 | @ForeignKey(optional = true, onForeignDeleted = OnForeignDeleted.SET_TO_NULL) 22 | private MyEntity3 parent; 23 | 24 | public Long getId() { 25 | return id; 26 | } 27 | 28 | public void setId(Long id) { 29 | this.id = id; 30 | } 31 | 32 | public String getSubValue() { 33 | return subValue; 34 | } 35 | 36 | public void setSubValue(String subValue) { 37 | this.subValue = subValue; 38 | } 39 | 40 | public MyEntity3 getParent() { 41 | return parent; 42 | } 43 | 44 | public void setParent(MyEntity3 parent) { 45 | this.parent = parent; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/onetoonemodel/MySubEntity4.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.onetoonemodel; 2 | 3 | import org.springframework.data.relational.core.mapping.Column; 4 | import org.springframework.data.relational.core.mapping.Table; 5 | 6 | import net.lecousin.reactive.data.relational.annotations.CompositeId; 7 | import net.lecousin.reactive.data.relational.annotations.ForeignKey; 8 | import net.lecousin.reactive.data.relational.annotations.ForeignKey.OnForeignDeleted; 9 | import reactor.core.publisher.Mono; 10 | 11 | @Table 12 | @CompositeId(indexName = "sub_entity_4_key", properties = {"value1", "value2"}) 13 | public class MySubEntity4 { 14 | 15 | @Column 16 | private String value1; 17 | 18 | @Column 19 | private String value2; 20 | 21 | @ForeignKey(optional = false) 22 | private MyEntity4 parent; 23 | 24 | @ForeignKey(optional = false, cascadeDelete = true, onForeignDeleted = OnForeignDeleted.DELETE) 25 | private MyEntity1 entity1; 26 | 27 | public String getValue1() { 28 | return value1; 29 | } 30 | 31 | public void setValue1(String value1) { 32 | this.value1 = value1; 33 | } 34 | 35 | public String getValue2() { 36 | return value2; 37 | } 38 | 39 | public void setValue2(String value2) { 40 | this.value2 = value2; 41 | } 42 | 43 | public MyEntity4 getParent() { 44 | return parent; 45 | } 46 | 47 | public void setParent(MyEntity4 parent) { 48 | this.parent = parent; 49 | } 50 | 51 | public MyEntity1 getEntity1() { 52 | return entity1; 53 | } 54 | 55 | public void setEntity1(MyEntity1 entity1) { 56 | this.entity1 = entity1; 57 | } 58 | 59 | public Mono lazyGetEntity1() { 60 | return null; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/onetoonemodel/MySubEntity5.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.onetoonemodel; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.relational.core.mapping.Column; 5 | import org.springframework.data.relational.core.mapping.Table; 6 | 7 | import net.lecousin.reactive.data.relational.annotations.ForeignKey; 8 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 9 | 10 | @Table 11 | public class MySubEntity5 { 12 | 13 | @Id 14 | @GeneratedValue 15 | private Long id; 16 | 17 | @Column 18 | private String subValue; 19 | 20 | @ForeignKey(optional = false, cascadeDelete = true) 21 | private MyEntity5 parent; 22 | 23 | public Long getId() { 24 | return id; 25 | } 26 | 27 | public void setId(Long id) { 28 | this.id = id; 29 | } 30 | 31 | public String getSubValue() { 32 | return subValue; 33 | } 34 | 35 | public void setSubValue(String subValue) { 36 | this.subValue = subValue; 37 | } 38 | 39 | public MyEntity5 getParent() { 40 | return parent; 41 | } 42 | 43 | public void setParent(MyEntity5 parent) { 44 | this.parent = parent; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/onetoonemodel/MySubEntity5Repository.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.onetoonemodel; 2 | 3 | import net.lecousin.reactive.data.relational.repository.LcR2dbcRepository; 4 | 5 | public interface MySubEntity5Repository extends LcR2dbcRepository { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/onetoonemodel/MySubEntity6.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.onetoonemodel; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.relational.core.mapping.Column; 5 | import org.springframework.data.relational.core.mapping.Table; 6 | 7 | import net.lecousin.reactive.data.relational.annotations.ForeignKey; 8 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 9 | 10 | @Table 11 | public class MySubEntity6 { 12 | 13 | @Id 14 | @GeneratedValue 15 | private Long id; 16 | 17 | @Column 18 | private String subValue; 19 | 20 | @ForeignKey(optional = false) 21 | private MyEntity6 parent; 22 | 23 | public Long getId() { 24 | return id; 25 | } 26 | 27 | public void setId(Long id) { 28 | this.id = id; 29 | } 30 | 31 | public String getSubValue() { 32 | return subValue; 33 | } 34 | 35 | public void setSubValue(String subValue) { 36 | this.subValue = subValue; 37 | } 38 | 39 | public MyEntity6 getParent() { 40 | return parent; 41 | } 42 | 43 | public void setParent(MyEntity6 parent) { 44 | this.parent = parent; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/onetoonemodel/MySubEntity6Repository.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.onetoonemodel; 2 | 3 | import net.lecousin.reactive.data.relational.repository.LcR2dbcRepository; 4 | 5 | public interface MySubEntity6Repository extends LcR2dbcRepository { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/onetoonemodel/package-info.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.onetoonemodel; -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/package-info.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test; -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/simplemodel/AllowEnhancer.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.simplemodel; 2 | 3 | public interface AllowEnhancer { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/simplemodel/BooleanTypes.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.simplemodel; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.relational.core.mapping.Column; 5 | import org.springframework.data.relational.core.mapping.Table; 6 | 7 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 8 | import reactor.core.publisher.Mono; 9 | 10 | @Table 11 | public class BooleanTypes { 12 | 13 | @Id 14 | @GeneratedValue 15 | private Long id; 16 | 17 | @Column 18 | private Boolean b1; 19 | 20 | @Column 21 | private boolean b2; 22 | 23 | public Long getId() { 24 | return id; 25 | } 26 | 27 | public Boolean getB1() { 28 | return b1; 29 | } 30 | 31 | public void setB1(Boolean b1) { 32 | this.b1 = b1; 33 | } 34 | 35 | public boolean isB2() { 36 | return b2; 37 | } 38 | 39 | public void setB2(boolean b2) { 40 | this.b2 = b2; 41 | } 42 | 43 | public String entityLoaded() { 44 | return "Not eligible"; 45 | } 46 | 47 | public boolean entityLoaded(boolean test) { 48 | return test; 49 | } 50 | 51 | public Mono loadEntity(@SuppressWarnings("unused") boolean test) { 52 | return null; 53 | } 54 | 55 | public boolean loadEntity() { 56 | return false; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/simplemodel/BooleanTypesRepository.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.simplemodel; 2 | 3 | import org.springframework.data.r2dbc.repository.Query; 4 | 5 | import net.lecousin.reactive.data.relational.query.SelectQuery; 6 | import net.lecousin.reactive.data.relational.repository.LcR2dbcRepository; 7 | import reactor.core.publisher.Flux; 8 | 9 | public interface BooleanTypesRepository extends LcR2dbcRepository { 10 | 11 | default Flux page(int start, int nb) { 12 | return SelectQuery.from(BooleanTypes.class, "b").limit(start, nb).execute(getLcClient()); 13 | } 14 | 15 | @Query("select b1, b2 from boolean_types") 16 | Flux findAllWithoutId(); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/simplemodel/CharacterTypesRepository.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.simplemodel; 2 | 3 | import net.lecousin.reactive.data.relational.repository.LcR2dbcRepository; 4 | 5 | public interface CharacterTypesRepository extends LcR2dbcRepository { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/simplemodel/CompositeIdEntity.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.simplemodel; 2 | 3 | import org.springframework.data.relational.core.mapping.Column; 4 | import org.springframework.data.relational.core.mapping.Table; 5 | 6 | import net.lecousin.reactive.data.relational.annotations.ColumnDefinition; 7 | import net.lecousin.reactive.data.relational.annotations.CompositeId; 8 | 9 | @Table 10 | @CompositeId(indexName = "composite_id_index", properties = {"id1", "id2"}) 11 | public class CompositeIdEntity { 12 | 13 | @Column 14 | private Long id1; 15 | 16 | @Column 17 | private String id2; 18 | 19 | @Column 20 | @ColumnDefinition(max = 20) 21 | private String str; 22 | 23 | public Long getId1() { 24 | return id1; 25 | } 26 | 27 | public void setId1(Long id1) { 28 | this.id1 = id1; 29 | } 30 | 31 | public String getId2() { 32 | return id2; 33 | } 34 | 35 | public void setId2(String id2) { 36 | this.id2 = id2; 37 | } 38 | 39 | public String getStr() { 40 | return str; 41 | } 42 | 43 | public void setStr(String str) { 44 | this.str = str; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/simplemodel/DateTypesRepository.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.simplemodel; 2 | 3 | import net.lecousin.reactive.data.relational.repository.LcR2dbcRepository; 4 | 5 | public interface DateTypesRepository extends LcR2dbcRepository { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/simplemodel/Entity1WithSequence.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.simplemodel; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.relational.core.mapping.Column; 5 | import org.springframework.data.relational.core.mapping.Table; 6 | 7 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 8 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue.Strategy; 9 | 10 | @Table 11 | public class Entity1WithSequence { 12 | 13 | @Id @GeneratedValue(strategy = Strategy.SEQUENCE, sequence = "my_sequence") 14 | private Long id; 15 | 16 | @Column("value") 17 | private String value; 18 | 19 | public Long getId() { 20 | return id; 21 | } 22 | 23 | public void setId(Long id) { 24 | this.id = id; 25 | } 26 | 27 | public String getValue() { 28 | return value; 29 | } 30 | 31 | public void setValue(String value) { 32 | this.value = value; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/simplemodel/Entity2WithSequence.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.simplemodel; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.relational.core.mapping.Column; 5 | import org.springframework.data.relational.core.mapping.Table; 6 | 7 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 8 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue.Strategy; 9 | 10 | @Table 11 | public class Entity2WithSequence { 12 | 13 | @Id @GeneratedValue(strategy = Strategy.SEQUENCE, sequence = "my_sequence") 14 | private Long id; 15 | 16 | @Column("value") 17 | private String value; 18 | 19 | public Long getId() { 20 | return id; 21 | } 22 | 23 | public void setId(Long id) { 24 | this.id = id; 25 | } 26 | 27 | public String getValue() { 28 | return value; 29 | } 30 | 31 | public void setValue(String value) { 32 | this.value = value; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/simplemodel/EnumEntity.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.simplemodel; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.relational.core.mapping.Column; 5 | import org.springframework.data.relational.core.mapping.Table; 6 | 7 | import net.lecousin.reactive.data.relational.annotations.ColumnDefinition; 8 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 9 | 10 | @Table 11 | public class EnumEntity { 12 | 13 | public enum Enum1 { 14 | V1, V2, V3; 15 | } 16 | 17 | @Id 18 | @GeneratedValue 19 | private Long id; 20 | 21 | @Column 22 | private int i; 23 | 24 | @Column 25 | @ColumnDefinition(nullable = false) 26 | private Enum1 e1; 27 | 28 | @Column 29 | @ColumnDefinition(nullable = true) 30 | private Enum1 e2; 31 | 32 | public Long getId() { 33 | return id; 34 | } 35 | 36 | public void setId(Long id) { 37 | this.id = id; 38 | } 39 | 40 | public int getI() { 41 | return i; 42 | } 43 | 44 | public void setI(int i) { 45 | this.i = i; 46 | } 47 | 48 | public Enum1 getE1() { 49 | return e1; 50 | } 51 | 52 | public void setE1(Enum1 e1) { 53 | this.e1 = e1; 54 | } 55 | 56 | public Enum1 getE2() { 57 | return e2; 58 | } 59 | 60 | public void setE2(Enum1 e2) { 61 | this.e2 = e2; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/simplemodel/EnumRepository.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.simplemodel; 2 | 3 | import net.lecousin.reactive.data.relational.repository.LcR2dbcRepository; 4 | 5 | public interface EnumRepository extends LcR2dbcRepository { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/simplemodel/NumericTypesRepository.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.simplemodel; 2 | 3 | import org.springframework.data.r2dbc.repository.Query; 4 | 5 | import net.lecousin.reactive.data.relational.repository.LcR2dbcRepository; 6 | import reactor.core.publisher.Flux; 7 | 8 | public interface NumericTypesRepository extends LcR2dbcRepository { 9 | 10 | Flux findByLong1(long long1); 11 | 12 | @Query("SELECT id, long1 FROM numeric_types") 13 | Flux getAllOnlyWithIdAndLong1(); 14 | 15 | @Query("SELECT long1 FROM numeric_types") 16 | Flux getAllLong1(); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/simplemodel/TransactionalService.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.simplemodel; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Service; 5 | import org.springframework.transaction.annotation.Transactional; 6 | 7 | import net.lecousin.reactive.data.relational.LcReactiveDataRelationalClient; 8 | import reactor.core.publisher.Flux; 9 | import reactor.core.publisher.Mono; 10 | 11 | @Service 12 | public class TransactionalService { 13 | 14 | @Autowired 15 | private LcReactiveDataRelationalClient lcClient; 16 | 17 | @Transactional 18 | public Mono createCorrectEntity() { 19 | CharacterTypes e = new CharacterTypes(); 20 | e.setFixedLengthString("abcde"); 21 | e.setLongString("Hello World"); 22 | return lcClient.save(e); 23 | } 24 | 25 | @Transactional 26 | public Flux createCorrectEntityThenInvalidEntity() { 27 | CharacterTypes e = new CharacterTypes(); 28 | e.setFixedLengthString("abcde"); 29 | e.setLongString("Hello World"); 30 | Mono save1 = lcClient.save(e); 31 | e = new CharacterTypes(); 32 | Mono save2 = lcClient.save(e); 33 | return Flux.concat(save1, save2); 34 | } 35 | 36 | @Transactional 37 | public Mono deleteEntity(CharacterTypes e) { 38 | return lcClient.delete(e); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/simplemodel/UUIDEntity.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.simplemodel; 2 | 3 | import java.util.UUID; 4 | 5 | import org.springframework.data.annotation.Id; 6 | import org.springframework.data.relational.core.mapping.Column; 7 | import org.springframework.data.relational.core.mapping.Table; 8 | 9 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 10 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue.Strategy; 11 | 12 | @Table 13 | public class UUIDEntity { 14 | 15 | @Id @GeneratedValue(strategy = Strategy.RANDOM_UUID) 16 | private UUID uuidKey; 17 | 18 | @Column 19 | private UUID uuidNonKey; 20 | 21 | @Column 22 | private int i; 23 | 24 | public UUID getUuidKey() { 25 | return uuidKey; 26 | } 27 | 28 | public void setUuidKey(UUID uuidKey) { 29 | this.uuidKey = uuidKey; 30 | } 31 | 32 | public UUID getUuidNonKey() { 33 | return uuidNonKey; 34 | } 35 | 36 | public void setUuidNonKey(UUID uuidNonKey) { 37 | this.uuidNonKey = uuidNonKey; 38 | } 39 | 40 | public int getI() { 41 | return i; 42 | } 43 | 44 | public void setI(int i) { 45 | this.i = i; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/simplemodel/UUIDEntityRepository.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.simplemodel; 2 | 3 | import java.util.UUID; 4 | 5 | import net.lecousin.reactive.data.relational.repository.LcR2dbcRepository; 6 | 7 | public interface UUIDEntityRepository extends LcR2dbcRepository { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/simplemodel/UpdatableProperties.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.simplemodel; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.annotation.ReadOnlyProperty; 5 | import org.springframework.data.relational.core.mapping.Column; 6 | import org.springframework.data.relational.core.mapping.Table; 7 | 8 | import net.lecousin.reactive.data.relational.annotations.ColumnDefinition; 9 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 10 | 11 | @Table 12 | public class UpdatableProperties { 13 | 14 | @Id @GeneratedValue 15 | private Long id; 16 | 17 | @Column 18 | private String str1; 19 | 20 | @ColumnDefinition(updatable = true) 21 | private String str2; 22 | 23 | @ColumnDefinition(updatable = false) 24 | private String str3; 25 | 26 | @Column @ReadOnlyProperty 27 | private String str4; 28 | 29 | public Long getId() { 30 | return id; 31 | } 32 | 33 | public void setId(Long id) { 34 | this.id = id; 35 | } 36 | 37 | public String getStr1() { 38 | return str1; 39 | } 40 | 41 | public void setStr1(String str1) { 42 | this.str1 = str1; 43 | } 44 | 45 | public String getStr2() { 46 | return str2; 47 | } 48 | 49 | public void setStr2(String str2) { 50 | this.str2 = str2; 51 | } 52 | 53 | public String getStr3() { 54 | return str3; 55 | } 56 | 57 | public void setStr3(String str3) { 58 | this.str3 = str3; 59 | } 60 | 61 | public String getStr4() { 62 | return str4; 63 | } 64 | 65 | public void setStr4(String str4) { 66 | this.str4 = str4; 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/simplemodel/VersionedEntityRepository.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.simplemodel; 2 | 3 | import net.lecousin.reactive.data.relational.repository.LcR2dbcRepository; 4 | 5 | public interface VersionedEntityRepository extends LcR2dbcRepository { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/simplemodel/package-info.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.simplemodel; -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/treemodel/AllowEnhancer.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.treemodel; 2 | 3 | public interface AllowEnhancer { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/treemodel/NodeRepository.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.treemodel; 2 | 3 | import net.lecousin.reactive.data.relational.query.SelectQuery; 4 | import net.lecousin.reactive.data.relational.query.criteria.Criteria; 5 | import net.lecousin.reactive.data.relational.repository.LcR2dbcRepository; 6 | import reactor.core.publisher.Flux; 7 | 8 | public interface NodeRepository extends LcR2dbcRepository { 9 | 10 | default Flux fetch1Level() { 11 | return SelectQuery.from(Node.class, "root") 12 | .where(Criteria.property("root", "parent").isNull()) 13 | .join("root", "children", "sub1") 14 | .execute(getLcClient()); 15 | } 16 | 17 | default Flux fetch2Levels() { 18 | return SelectQuery.from(Node.class, "root") 19 | .where(Criteria.property("root", "parent").isNull()) 20 | .join("root", "children", "sub1") 21 | .join("sub1", "children", "sub2") 22 | .execute(getLcClient()); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/test/treemodel/package-info.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test.treemodel; -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/tests/MyWrongConfiguration.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.tests; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.data.r2dbc.dialect.R2dbcDialect; 5 | 6 | import net.lecousin.reactive.data.relational.configuration.LcReactiveDataRelationalConfiguration; 7 | import net.lecousin.reactive.data.relational.schema.dialect.RelationalDatabaseSchemaDialect; 8 | 9 | @Configuration 10 | public class MyWrongConfiguration extends LcReactiveDataRelationalConfiguration { 11 | 12 | @Override 13 | public RelationalDatabaseSchemaDialect schemaDialect() { 14 | return new RelationalDatabaseSchemaDialect() { 15 | @Override 16 | public boolean isCompatible(R2dbcDialect r2dbcDialect) { 17 | return true; 18 | } 19 | 20 | @Override 21 | public String getName() { 22 | return "Fake"; 23 | } 24 | }; 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/tests/TestCompositeIdValue.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.tests; 2 | 3 | import org.junit.jupiter.api.Assertions; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import net.lecousin.reactive.data.relational.model.CompositeIdValue; 7 | 8 | class TestCompositeIdValue { 9 | 10 | @Test 11 | void test() { 12 | CompositeIdValue c = new CompositeIdValue(); 13 | CompositeIdValue c2 = new CompositeIdValue(); 14 | Assertions.assertTrue(c.isNull()); 15 | Assertions.assertFalse(c.equals(null)); 16 | Assertions.assertTrue(c.equals(c2)); 17 | Assertions.assertTrue(c2.equals(c)); 18 | Assertions.assertEquals(c.hashCode(), c2.hashCode()); 19 | c2.add("test", 1); 20 | Assertions.assertFalse(c.equals(c2)); 21 | Assertions.assertFalse(c2.equals(c)); 22 | Assertions.assertFalse(c2.isNull()); 23 | c.add("test", 1); 24 | Assertions.assertTrue(c.equals(c2)); 25 | Assertions.assertTrue(c2.equals(c)); 26 | Assertions.assertEquals(c.hashCode(), c2.hashCode()); 27 | Assertions.assertFalse(c.isNull()); 28 | c2.add("test2", null); 29 | Assertions.assertFalse(c2.isNull()); 30 | Assertions.assertFalse(c.equals(c2)); 31 | Assertions.assertFalse(c2.equals(c)); 32 | c2.hashCode(); 33 | c.add("test2", 2); 34 | Assertions.assertFalse(c.equals(c2)); 35 | Assertions.assertFalse(c2.equals(c)); 36 | c2.add("test2", 2); 37 | Assertions.assertTrue(c.equals(c2)); 38 | Assertions.assertTrue(c2.equals(c)); 39 | c.add("test3", 3); 40 | c2.add("test4", 4); 41 | Assertions.assertFalse(c.equals(c2)); 42 | Assertions.assertFalse(c2.equals(c)); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/tests/TestInsertMultipleToString.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.tests; 2 | 3 | import java.util.Arrays; 4 | import java.util.LinkedList; 5 | import java.util.List; 6 | 7 | import org.junit.jupiter.api.Assertions; 8 | import org.junit.jupiter.api.Test; 9 | import org.springframework.data.relational.core.sql.Column; 10 | import org.springframework.data.relational.core.sql.Expression; 11 | import org.springframework.data.relational.core.sql.SQL; 12 | import org.springframework.data.relational.core.sql.Table; 13 | 14 | import net.lecousin.reactive.data.relational.query.InsertMultiple; 15 | 16 | class TestInsertMultipleToString { 17 | 18 | @Test 19 | void test() { 20 | Table table = Table.create("my_table"); 21 | Column col1 = Column.create("col1", table); 22 | Column col2 = Column.create("col2", table); 23 | Column col3 = Column.create("col3", table); 24 | List> values = new LinkedList<>(); 25 | values.add(Arrays.asList(SQL.literalOf(true), SQL.literalOf(10), SQL.nullLiteral())); 26 | values.add(Arrays.asList(SQL.nullLiteral(), SQL.literalOf(false), SQL.literalOf(5))); 27 | InsertMultiple im = new InsertMultiple(table, Arrays.asList(col1, col2, col3), values); 28 | Assertions.assertEquals("INSERT INTO my_table (col1,col2,col3) VALUES (TRUE,10,NULL),(NULL,FALSE,5)", im.toString()); 29 | Assertions.assertEquals("INSERT INTO my_table (col1,col2,col3) VALUES (TRUE,10,NULL),(NULL,FALSE,5)", im.render(null)); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/tests/TestIterables.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.tests; 2 | 3 | import java.util.Arrays; 4 | import java.util.Iterator; 5 | import java.util.NoSuchElementException; 6 | 7 | import org.junit.jupiter.api.Assertions; 8 | import org.junit.jupiter.api.Test; 9 | 10 | import net.lecousin.reactive.data.relational.util.Iterables; 11 | 12 | class TestIterables { 13 | 14 | @Test 15 | void testFilterIterable() { 16 | Iterable iterable = Arrays.asList(10, 11, 12, 13, 14, 15); 17 | Iterable filtered = Iterables.filter(iterable, i -> (i % 2) == 0); 18 | Iterator it = filtered.iterator(); 19 | Assertions.assertTrue(it.hasNext()); 20 | Assertions.assertEquals(10, it.next()); 21 | Assertions.assertTrue(it.hasNext()); 22 | Assertions.assertEquals(12, it.next()); 23 | Assertions.assertTrue(it.hasNext()); 24 | Assertions.assertEquals(14, it.next()); 25 | Assertions.assertFalse(it.hasNext()); 26 | Assertions.assertThrows(NoSuchElementException.class, () -> it.next()); 27 | } 28 | 29 | @Test 30 | void testMapIterable() { 31 | Iterable iterable = Arrays.asList(10, 11, 12, 13, 14, 15); 32 | Iterable mapped = Iterables.map(iterable, i -> i.toString()); 33 | Iterator it = mapped.iterator(); 34 | Assertions.assertTrue(it.hasNext()); 35 | Assertions.assertEquals("10", it.next()); 36 | Assertions.assertTrue(it.hasNext()); 37 | Assertions.assertEquals("11", it.next()); 38 | Assertions.assertTrue(it.hasNext()); 39 | Assertions.assertEquals("12", it.next()); 40 | Assertions.assertTrue(it.hasNext()); 41 | Assertions.assertEquals("13", it.next()); 42 | Assertions.assertTrue(it.hasNext()); 43 | Assertions.assertEquals("14", it.next()); 44 | Assertions.assertTrue(it.hasNext()); 45 | Assertions.assertEquals("15", it.next()); 46 | Assertions.assertFalse(it.hasNext()); 47 | Assertions.assertThrows(NoSuchElementException.class, () -> it.next()); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/tests/TestWrongConfiguration.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.tests; 2 | 3 | import org.junit.jupiter.api.Assertions; 4 | import org.junit.jupiter.api.Test; 5 | import org.junit.jupiter.api.extension.ExtendWith; 6 | import org.springframework.beans.BeansException; 7 | import org.springframework.context.ApplicationContext; 8 | import org.springframework.context.ApplicationContextAware; 9 | import org.springframework.test.annotation.DirtiesContext; 10 | import org.springframework.test.annotation.DirtiesContext.ClassMode; 11 | import org.springframework.test.context.junit.jupiter.SpringExtension; 12 | 13 | @ExtendWith(SpringExtension.class) 14 | @DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD) 15 | class TestWrongConfiguration implements ApplicationContextAware { 16 | 17 | private ApplicationContext applicationContext; 18 | 19 | @Override 20 | public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { 21 | this.applicationContext = applicationContext; 22 | } 23 | 24 | @Test 25 | void testConfigurationClassWithoutConnectionFactory() { 26 | MyWrongConfiguration cfg = new MyWrongConfiguration(); 27 | 28 | Assertions.assertNull(cfg.connectionFactory()); 29 | 30 | try { 31 | cfg.reactiveDataAccessStrategy(null); 32 | throw new AssertionError("Application context not initialized expected"); 33 | } catch (Exception e) { 34 | Assertions.assertEquals("ApplicationContext is not yet initialized", e.getMessage()); 35 | } 36 | 37 | cfg.setApplicationContext(applicationContext); 38 | 39 | 40 | try { 41 | cfg.reactiveDataAccessStrategy(null); 42 | throw new AssertionError("No connection factory error expected"); 43 | } catch (Exception e) { 44 | Assertions.assertEquals("No r2dbc connection factory defined", e.getMessage()); 45 | } 46 | 47 | Assertions.assertThrows(IllegalArgumentException.class, () -> cfg.r2dbcConverter(null, null)); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/tests/invalid/InvalidJoinTable1.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.tests.invalid; 2 | 3 | import org.springframework.data.relational.core.mapping.Table; 4 | 5 | import net.lecousin.reactive.data.relational.annotations.JoinTable; 6 | 7 | @Table 8 | public class InvalidJoinTable1 { 9 | 10 | @JoinTable 11 | private InvalidJoinTable2 join; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/tests/invalid/InvalidJoinTable2.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.tests.invalid; 2 | 3 | import org.springframework.data.relational.core.mapping.Table; 4 | 5 | @Table 6 | public class InvalidJoinTable2 { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/tests/invalid/InvalidJoinTable3.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.tests.invalid; 2 | 3 | import java.util.Set; 4 | 5 | import org.springframework.data.annotation.Id; 6 | import org.springframework.data.relational.core.mapping.Table; 7 | 8 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 9 | import net.lecousin.reactive.data.relational.annotations.JoinTable; 10 | import reactor.core.publisher.Mono; 11 | 12 | @Table 13 | public class InvalidJoinTable3 { 14 | 15 | @Id @GeneratedValue 16 | private Long id; 17 | 18 | @JoinTable 19 | private Set join; 20 | 21 | public Mono lazyGetJoin() { 22 | return null; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/tests/invalid/InvalidJoinTable4.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.tests.invalid; 2 | 3 | import java.util.Set; 4 | 5 | import org.springframework.data.annotation.Id; 6 | import org.springframework.data.relational.core.mapping.Table; 7 | 8 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 9 | import net.lecousin.reactive.data.relational.annotations.JoinTable; 10 | 11 | @Table 12 | public class InvalidJoinTable4 { 13 | 14 | @Id @GeneratedValue 15 | private Long id; 16 | 17 | @JoinTable 18 | private Set join; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/tests/invalid/InvalidJoinTable5.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.tests.invalid; 2 | 3 | import java.util.Set; 4 | 5 | import org.springframework.data.annotation.Id; 6 | import org.springframework.data.relational.core.mapping.Table; 7 | 8 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 9 | import net.lecousin.reactive.data.relational.annotations.JoinTable; 10 | 11 | @Table 12 | public class InvalidJoinTable5 { 13 | 14 | @Id @GeneratedValue 15 | private Long id; 16 | 17 | @JoinTable 18 | private Set join; 19 | 20 | public void setJoin() { 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/tests/invalid/InvalidJoinTable6.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.tests.invalid; 2 | 3 | import java.util.Set; 4 | 5 | import org.springframework.data.annotation.Id; 6 | import org.springframework.data.relational.core.mapping.Table; 7 | 8 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 9 | import net.lecousin.reactive.data.relational.annotations.JoinTable; 10 | 11 | @Table 12 | public class InvalidJoinTable6 { 13 | 14 | @Id @GeneratedValue 15 | private Long id; 16 | 17 | @JoinTable 18 | private Set join; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/tests/invalid/NonEntity.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.tests.invalid; 2 | 3 | public class NonEntity { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/java/net/lecousin/reactive/data/relational/tests/package-info.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.tests; -------------------------------------------------------------------------------- /core/src/test/resources/application.yaml: -------------------------------------------------------------------------------- 1 | spring: 2 | main: 3 | banner-mode: "off" 4 | -------------------------------------------------------------------------------- /core/src/test/resources/lc-reactive-data-relational.yaml: -------------------------------------------------------------------------------- 1 | entities: 2 | - net.lecousin.reactive.data.relational.test: 3 | - EntityWithTransientFields 4 | - EntityWithNonNullProperty 5 | - simplemodel: 6 | - BooleanTypes 7 | - CharacterTypes 8 | - CompositeIdEntity 9 | - DateTypes 10 | - DateTypesWithTimeZone 11 | - Entity1WithSequence 12 | - Entity2WithSequence 13 | - EnumEntity 14 | - NumericTypes 15 | - UpdatableProperties 16 | - UUIDEntity 17 | - VersionedEntity 18 | - onetoonemodel: 19 | - MyEntity1 20 | - MySubEntity1 21 | - MyEntity2 22 | - MySubEntity2 23 | - MyEntity3 24 | - MySubEntity3 25 | - MyEntity4 26 | - MySubEntity4 27 | - MyEntity5 28 | - MySubEntity5 29 | - MyEntity6 30 | - MySubEntity6 31 | - MyEntity1WithConstructor 32 | - MySubEntity1WithConstructor 33 | - onetomanymodel: 34 | - RootEntity 35 | - SubEntity 36 | - SubEntity2 37 | - SubEntity3 38 | - RootEntityWithConstructor 39 | - SubEntityWithConstructor 40 | - manytomanymodel: 41 | - Entity1 42 | - Entity2 43 | - JoinEntity 44 | - Entity3 45 | - Entity4 46 | - model1: 47 | - Company 48 | - Employee 49 | - Person 50 | - PointOfContact 51 | - PostalAddress 52 | - Site 53 | - User 54 | - treemodel: 55 | - Node 56 | - envelopemodel: 57 | - Envelope 58 | - Document 59 | - Page 60 | - Note 61 | - multipleconnections: 62 | - db1: 63 | - MultipleDbEntity1 64 | - db2: 65 | - MultipleDbEntity2 66 | - arraycolumns: 67 | - EntityWithArrays 68 | -------------------------------------------------------------------------------- /core/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 16 | 17 | -------------------------------------------------------------------------------- /h2/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /h2/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | net.lecousin.reactive-data-relational.h2 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.springframework.ide.eclipse.boot.validation.springbootbuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.m2e.core.maven2Builder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.jdt.core.javanature 26 | org.eclipse.m2e.core.maven2Nature 27 | 28 | 29 | -------------------------------------------------------------------------------- /h2/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding//src/test/java=UTF-8 5 | encoding/=UTF-8 6 | -------------------------------------------------------------------------------- /h2/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 3 | org.eclipse.jdt.core.compiler.compliance=11 4 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 5 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 6 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore 7 | org.eclipse.jdt.core.compiler.release=enabled 8 | org.eclipse.jdt.core.compiler.source=11 9 | -------------------------------------------------------------------------------- /h2/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /h2/.settings/org.sonarlint.eclipse.core.prefs: -------------------------------------------------------------------------------- 1 | autoEnabled=true 2 | eclipse.preferences.version=1 3 | idePrefixKey= 4 | projectKey=lecousin_lc-spring-data-r2dbc 5 | serverId=SonarCloud/lecousin 6 | sqPrefixKey=h2 7 | -------------------------------------------------------------------------------- /h2/.settings/org.springframework.ide.eclipse.prefs: -------------------------------------------------------------------------------- 1 | boot.validation.initialized=true 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /h2/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | net.lecousin.reactive-data-relational 5 | parent 6 | 0.10.2 7 | 8 | h2 9 | 10 | 11 | ${project.basedir}/../jacoco-report-aggregate/target/site/jacoco-aggregate/jacoco.xml 12 | 13 | 14 | 15 | 16 | ${project.groupId} 17 | core 18 | ${project.version} 19 | 20 | 21 | 22 | io.r2dbc 23 | r2dbc-h2 24 | ${r2dbc-h2.version} 25 | 26 | 27 | 28 | ${project.groupId} 29 | core 30 | ${project.version} 31 | test-jar 32 | test 33 | 34 | 35 | 36 | ${project.groupId} 37 | test-junit-5 38 | ${project.version} 39 | test 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /h2/src/main/java/net/lecousin/reactive/data/relational/h2/H2Configuration.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.h2; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | import net.lecousin.reactive.data.relational.configuration.LcReactiveDataRelationalConfiguration; 7 | 8 | @Configuration 9 | public class H2Configuration extends LcReactiveDataRelationalConfiguration { 10 | 11 | @Bean 12 | @Override 13 | public H2SchemaDialect schemaDialect() { 14 | return new H2SchemaDialect(); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /h2/src/main/resources/META-INF/services/net.lecousin.reactive.data.relational.schema.dialect.RelationalDatabaseSchemaDialect: -------------------------------------------------------------------------------- 1 | net.lecousin.reactive.data.relational.h2.H2SchemaDialect -------------------------------------------------------------------------------- /h2/src/test/java/net/lecousin/reactive/data/relational/h2/test/H2TestConfiguration.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.h2.test; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | import io.r2dbc.spi.ConnectionFactories; 7 | import io.r2dbc.spi.ConnectionFactory; 8 | import net.lecousin.reactive.data.relational.h2.H2Configuration; 9 | 10 | @Configuration 11 | public class H2TestConfiguration extends H2Configuration { 12 | 13 | @Override 14 | @Bean 15 | public ConnectionFactory connectionFactory() { 16 | return ConnectionFactories.get("r2dbc:pool:h2:mem:///test;DB_CLOSE_DELAY=-1;"); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /h2/src/test/java/net/lecousin/reactive/data/relational/h2/test/TestBasic.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.h2.test; 2 | 3 | import org.springframework.test.context.ContextConfiguration; 4 | 5 | import net.lecousin.reactive.data.relational.h2.H2SchemaDialect; 6 | import net.lecousin.reactive.data.relational.schema.dialect.RelationalDatabaseSchemaDialect; 7 | import net.lecousin.reactive.data.relational.test.AbstractBasicTest; 8 | 9 | @ContextConfiguration(classes = { H2TestConfiguration.class }) 10 | public class TestBasic extends AbstractBasicTest { 11 | 12 | @Override 13 | protected Class expectedDialect() { 14 | return H2SchemaDialect.class; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /h2/src/test/java/net/lecousin/reactive/data/relational/h2/test/TestEnvelopeModel.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.h2.test; 2 | 3 | import org.springframework.test.context.ContextConfiguration; 4 | 5 | import net.lecousin.reactive.data.relational.test.envelopemodel.AbstractTestEnvelopeModel; 6 | 7 | @ContextConfiguration(classes = { H2TestConfiguration.class }) 8 | public class TestEnvelopeModel extends AbstractTestEnvelopeModel { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /h2/src/test/java/net/lecousin/reactive/data/relational/h2/test/TestManyToMany.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.h2.test; 2 | 3 | import org.springframework.test.context.ContextConfiguration; 4 | 5 | import net.lecousin.reactive.data.relational.test.manytomanymodel.AbstractTestManyToManyModel; 6 | 7 | @ContextConfiguration(classes = { H2TestConfiguration.class }) 8 | public class TestManyToMany extends AbstractTestManyToManyModel { 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /h2/src/test/java/net/lecousin/reactive/data/relational/h2/test/TestModel1.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.h2.test; 2 | 3 | import org.springframework.test.context.ContextConfiguration; 4 | 5 | import net.lecousin.reactive.data.relational.test.model1.AbstractTestModel1; 6 | 7 | @ContextConfiguration(classes = { H2TestConfiguration.class }) 8 | public class TestModel1 extends AbstractTestModel1 { 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /h2/src/test/java/net/lecousin/reactive/data/relational/h2/test/TestMultipleConnections.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.h2.test; 2 | 3 | import org.springframework.beans.factory.annotation.Qualifier; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.test.context.ContextConfiguration; 7 | 8 | import net.lecousin.reactive.data.relational.test.multipleconnections.TestMultipleDatabaseConnections; 9 | 10 | @ContextConfiguration(classes = TestMultipleConnections.H2DbUrls.class) 11 | public class TestMultipleConnections extends TestMultipleDatabaseConnections { 12 | 13 | @Configuration 14 | public static class H2DbUrls implements DbUrls { 15 | @Override 16 | @Bean 17 | @Qualifier("db1Url") 18 | public String getFirstDbConnectionUrl() { 19 | return "r2dbc:pool:h2:mem:///db1;DB_CLOSE_DELAY=-1;"; 20 | } 21 | 22 | @Override 23 | @Bean 24 | @Qualifier("db2Url") 25 | public String getSecondDbConnectionUrl() { 26 | return "r2dbc:pool:h2:mem:///db2;DB_CLOSE_DELAY=-1;"; 27 | } 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /h2/src/test/java/net/lecousin/reactive/data/relational/h2/test/TestOneToMany.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.h2.test; 2 | 3 | import org.springframework.test.context.ContextConfiguration; 4 | 5 | import net.lecousin.reactive.data.relational.test.onetomanymodel.AbstractTestOneToManyModel; 6 | 7 | @ContextConfiguration(classes = { H2TestConfiguration.class }) 8 | public class TestOneToMany extends AbstractTestOneToManyModel { 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /h2/src/test/java/net/lecousin/reactive/data/relational/h2/test/TestOneToOne.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.h2.test; 2 | 3 | import org.springframework.test.context.ContextConfiguration; 4 | 5 | import net.lecousin.reactive.data.relational.test.onetoonemodel.AbstractTestOneToOneModel; 6 | 7 | @ContextConfiguration(classes = { H2TestConfiguration.class }) 8 | public class TestOneToOne extends AbstractTestOneToOneModel { 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /h2/src/test/java/net/lecousin/reactive/data/relational/h2/test/TestSimple.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.h2.test; 2 | 3 | import org.springframework.test.context.ContextConfiguration; 4 | 5 | import net.lecousin.reactive.data.relational.test.simplemodel.AbstractTestSimpleModel; 6 | 7 | @ContextConfiguration(classes = { H2TestConfiguration.class }) 8 | public class TestSimple extends AbstractTestSimpleModel { 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /h2/src/test/java/net/lecousin/reactive/data/relational/h2/test/TestTree.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.h2.test; 2 | 3 | import org.springframework.test.context.ContextConfiguration; 4 | 5 | import net.lecousin.reactive.data.relational.test.treemodel.AbstractTestTreeModel; 6 | 7 | @ContextConfiguration(classes = { H2TestConfiguration.class }) 8 | public class TestTree extends AbstractTestTreeModel { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /jacoco-report-aggregate/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | net.lecousin.reactive-data-relational.jacoco-report-aggregate 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.m2e.core.maven2Builder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.m2e.core.maven2Nature 16 | 17 | 18 | -------------------------------------------------------------------------------- /jacoco-report-aggregate/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /jacoco-report-aggregate/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /mysql/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /mysql/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | net.lecousin.reactive-data-relational.mysql 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.springframework.ide.eclipse.boot.validation.springbootbuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.m2e.core.maven2Builder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.jdt.core.javanature 26 | org.eclipse.m2e.core.maven2Nature 27 | 28 | 29 | -------------------------------------------------------------------------------- /mysql/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding//src/test/java=UTF-8 5 | encoding/=UTF-8 6 | -------------------------------------------------------------------------------- /mysql/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 3 | org.eclipse.jdt.core.compiler.compliance=11 4 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 5 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 6 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore 7 | org.eclipse.jdt.core.compiler.release=enabled 8 | org.eclipse.jdt.core.compiler.source=11 9 | -------------------------------------------------------------------------------- /mysql/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /mysql/.settings/org.sonarlint.eclipse.core.prefs: -------------------------------------------------------------------------------- 1 | autoEnabled=true 2 | eclipse.preferences.version=1 3 | idePrefixKey= 4 | projectKey=lecousin_lc-spring-data-r2dbc 5 | serverId=SonarCloud/lecousin 6 | sqPrefixKey=mysql 7 | -------------------------------------------------------------------------------- /mysql/.settings/org.springframework.ide.eclipse.prefs: -------------------------------------------------------------------------------- 1 | boot.validation.initialized=true 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /mysql/src/main/java/net/lecousin/reactive/data/relational/mysql/MySqlConfiguration.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.mysql; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | import net.lecousin.reactive.data.relational.configuration.LcReactiveDataRelationalConfiguration; 7 | 8 | @Configuration 9 | public class MySqlConfiguration extends LcReactiveDataRelationalConfiguration { 10 | 11 | @Bean 12 | @Override 13 | public MySqlSchemaDialect schemaDialect() { 14 | return new MySqlSchemaDialect(); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /mysql/src/main/resources/META-INF/services/net.lecousin.reactive.data.relational.schema.dialect.RelationalDatabaseSchemaDialect: -------------------------------------------------------------------------------- 1 | net.lecousin.reactive.data.relational.mysql.MySqlSchemaDialect -------------------------------------------------------------------------------- /mysql/src/test/java/net/lecousin/reactive/data/relational/mysql/test/v5_7_27/MySql_v5_7_27_TestConfiguration.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.mysql.test.v5_7_27; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | import io.r2dbc.spi.ConnectionFactories; 7 | import io.r2dbc.spi.ConnectionFactory; 8 | import net.lecousin.reactive.data.relational.mysql.MySqlConfiguration; 9 | import net.lecousin.reactive.data.relational.mysql.test.MySqlStarter; 10 | 11 | @Configuration 12 | public class MySql_v5_7_27_TestConfiguration extends MySqlConfiguration { 13 | 14 | @Bean 15 | public MySqlStarter mysql() { 16 | return new MySqlStarter(com.wix.mysql.distribution.Version.v5_7_27); 17 | } 18 | 19 | @Override 20 | @Bean 21 | public ConnectionFactory connectionFactory() { 22 | return ConnectionFactories.get( 23 | "r2dbcs:pool:mysql://auser:sa@127.0.0.1:" + MySqlStarter.getPort() + "/test?sslMode=preferred" 24 | ); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /mysql/src/test/java/net/lecousin/reactive/data/relational/mysql/test/v5_7_27/TestBasic.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.mysql.test.v5_7_27; 2 | 3 | import org.springframework.test.context.ContextConfiguration; 4 | 5 | import net.lecousin.reactive.data.relational.mysql.MySqlSchemaDialect; 6 | import net.lecousin.reactive.data.relational.schema.dialect.RelationalDatabaseSchemaDialect; 7 | import net.lecousin.reactive.data.relational.test.AbstractBasicTest; 8 | 9 | @ContextConfiguration(classes = { MySql_v5_7_27_TestConfiguration.class }) 10 | public class TestBasic extends AbstractBasicTest { 11 | 12 | @Override 13 | protected Class expectedDialect() { 14 | return MySqlSchemaDialect.class; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /mysql/src/test/java/net/lecousin/reactive/data/relational/mysql/test/v5_7_27/TestEnvelopeModel.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.mysql.test.v5_7_27; 2 | 3 | import org.springframework.test.context.ContextConfiguration; 4 | 5 | import net.lecousin.reactive.data.relational.test.envelopemodel.AbstractTestEnvelopeModel; 6 | 7 | @ContextConfiguration(classes = { MySql_v5_7_27_TestConfiguration.class }) 8 | public class TestEnvelopeModel extends AbstractTestEnvelopeModel { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /mysql/src/test/java/net/lecousin/reactive/data/relational/mysql/test/v5_7_27/TestManyToMany.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.mysql.test.v5_7_27; 2 | 3 | import org.springframework.test.context.ContextConfiguration; 4 | 5 | import net.lecousin.reactive.data.relational.test.manytomanymodel.AbstractTestManyToManyModel; 6 | 7 | @ContextConfiguration(classes = { MySql_v5_7_27_TestConfiguration.class }) 8 | public class TestManyToMany extends AbstractTestManyToManyModel { 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /mysql/src/test/java/net/lecousin/reactive/data/relational/mysql/test/v5_7_27/TestModel1.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.mysql.test.v5_7_27; 2 | 3 | import org.springframework.test.context.ContextConfiguration; 4 | 5 | import net.lecousin.reactive.data.relational.test.model1.AbstractTestModel1; 6 | 7 | @ContextConfiguration(classes = { MySql_v5_7_27_TestConfiguration.class }) 8 | public class TestModel1 extends AbstractTestModel1 { 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /mysql/src/test/java/net/lecousin/reactive/data/relational/mysql/test/v5_7_27/TestMultipleConnections.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.mysql.test.v5_7_27; 2 | 3 | import org.springframework.beans.factory.annotation.Qualifier; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.test.context.ContextConfiguration; 7 | 8 | import net.lecousin.reactive.data.relational.mysql.test.MySqlStarter; 9 | import net.lecousin.reactive.data.relational.test.multipleconnections.TestMultipleDatabaseConnections; 10 | 11 | @ContextConfiguration(classes = TestMultipleConnections.MySqlDbUrls.class) 12 | public class TestMultipleConnections extends TestMultipleDatabaseConnections { 13 | 14 | @Configuration 15 | public static class MySqlDbUrls implements DbUrls { 16 | @Bean 17 | public MySqlStarter mysql() { 18 | return new MySqlStarter(com.wix.mysql.distribution.Version.v5_7_27); 19 | } 20 | 21 | @Override 22 | @Bean 23 | @Qualifier("db1Url") 24 | public String getFirstDbConnectionUrl() { 25 | return "r2dbcs:pool:mysql://auser:sa@127.0.0.1:" + MySqlStarter.getPort() + "/first?sslMode=preferred"; 26 | } 27 | 28 | @Override 29 | @Bean 30 | @Qualifier("db2Url") 31 | public String getSecondDbConnectionUrl() { 32 | return "r2dbcs:pool:mysql://auser:sa@127.0.0.1:" + MySqlStarter.getPort() + "/second?sslMode=preferred"; 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /mysql/src/test/java/net/lecousin/reactive/data/relational/mysql/test/v5_7_27/TestOneToMany.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.mysql.test.v5_7_27; 2 | 3 | import org.springframework.test.context.ContextConfiguration; 4 | 5 | import net.lecousin.reactive.data.relational.test.onetomanymodel.AbstractTestOneToManyModel; 6 | 7 | @ContextConfiguration(classes = { MySql_v5_7_27_TestConfiguration.class }) 8 | public class TestOneToMany extends AbstractTestOneToManyModel { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /mysql/src/test/java/net/lecousin/reactive/data/relational/mysql/test/v5_7_27/TestOneToOne.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.mysql.test.v5_7_27; 2 | 3 | import org.springframework.test.context.ContextConfiguration; 4 | 5 | import net.lecousin.reactive.data.relational.test.onetoonemodel.AbstractTestOneToOneModel; 6 | 7 | @ContextConfiguration(classes = { MySql_v5_7_27_TestConfiguration.class }) 8 | public class TestOneToOne extends AbstractTestOneToOneModel { 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /mysql/src/test/java/net/lecousin/reactive/data/relational/mysql/test/v5_7_27/TestSimple.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.mysql.test.v5_7_27; 2 | 3 | import org.springframework.test.context.ContextConfiguration; 4 | 5 | import net.lecousin.reactive.data.relational.test.simplemodel.AbstractTestSimpleModel; 6 | 7 | @ContextConfiguration(classes = { MySql_v5_7_27_TestConfiguration.class }) 8 | public class TestSimple extends AbstractTestSimpleModel { 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /mysql/src/test/java/net/lecousin/reactive/data/relational/mysql/test/v5_7_27/TestTree.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.mysql.test.v5_7_27; 2 | 3 | import org.springframework.test.context.ContextConfiguration; 4 | 5 | import net.lecousin.reactive.data.relational.test.treemodel.AbstractTestTreeModel; 6 | 7 | @ContextConfiguration(classes = { MySql_v5_7_27_TestConfiguration.class }) 8 | public class TestTree extends AbstractTestTreeModel { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /mysql/src/test/java/net/lecousin/reactive/data/relational/mysql/test/v8_0_17/MySql_v8_0_17_TestConfiguration.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.mysql.test.v8_0_17; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | import io.r2dbc.spi.ConnectionFactories; 7 | import io.r2dbc.spi.ConnectionFactory; 8 | import net.lecousin.reactive.data.relational.mysql.MySqlConfiguration; 9 | import net.lecousin.reactive.data.relational.mysql.test.MySqlStarter; 10 | 11 | @Configuration 12 | public class MySql_v8_0_17_TestConfiguration extends MySqlConfiguration { 13 | 14 | @Bean 15 | public MySqlStarter mysql() { 16 | return new MySqlStarter(com.wix.mysql.distribution.Version.v8_0_17); 17 | } 18 | 19 | @Override 20 | @Bean 21 | public ConnectionFactory connectionFactory() { 22 | return ConnectionFactories.get( 23 | "r2dbcs:pool:mysql://auser:sa@127.0.0.1:" + MySqlStarter.getPort() + "/test" 24 | ); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /mysql/src/test/java/net/lecousin/reactive/data/relational/mysql/test/v8_0_17/TestBasic.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.mysql.test.v8_0_17; 2 | 3 | import org.springframework.test.context.ContextConfiguration; 4 | 5 | import net.lecousin.reactive.data.relational.mysql.MySqlSchemaDialect; 6 | import net.lecousin.reactive.data.relational.schema.dialect.RelationalDatabaseSchemaDialect; 7 | import net.lecousin.reactive.data.relational.test.AbstractBasicTest; 8 | 9 | @ContextConfiguration(classes = { MySql_v8_0_17_TestConfiguration.class }) 10 | public class TestBasic extends AbstractBasicTest { 11 | 12 | @Override 13 | protected Class expectedDialect() { 14 | return MySqlSchemaDialect.class; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /mysql/src/test/java/net/lecousin/reactive/data/relational/mysql/test/v8_0_17/TestEnvelopeModel.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.mysql.test.v8_0_17; 2 | 3 | import org.springframework.test.context.ContextConfiguration; 4 | 5 | import net.lecousin.reactive.data.relational.test.envelopemodel.AbstractTestEnvelopeModel; 6 | 7 | @ContextConfiguration(classes = { MySql_v8_0_17_TestConfiguration.class }) 8 | public class TestEnvelopeModel extends AbstractTestEnvelopeModel { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /mysql/src/test/java/net/lecousin/reactive/data/relational/mysql/test/v8_0_17/TestManyToMany.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.mysql.test.v8_0_17; 2 | 3 | import org.springframework.test.context.ContextConfiguration; 4 | 5 | import net.lecousin.reactive.data.relational.test.manytomanymodel.AbstractTestManyToManyModel; 6 | 7 | @ContextConfiguration(classes = { MySql_v8_0_17_TestConfiguration.class }) 8 | public class TestManyToMany extends AbstractTestManyToManyModel { 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /mysql/src/test/java/net/lecousin/reactive/data/relational/mysql/test/v8_0_17/TestModel1.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.mysql.test.v8_0_17; 2 | 3 | import org.springframework.test.context.ContextConfiguration; 4 | 5 | import net.lecousin.reactive.data.relational.test.model1.AbstractTestModel1; 6 | 7 | @ContextConfiguration(classes = { MySql_v8_0_17_TestConfiguration.class }) 8 | public class TestModel1 extends AbstractTestModel1 { 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /mysql/src/test/java/net/lecousin/reactive/data/relational/mysql/test/v8_0_17/TestMultipleConnections.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.mysql.test.v8_0_17; 2 | 3 | import org.springframework.beans.factory.annotation.Qualifier; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.test.context.ContextConfiguration; 7 | 8 | import net.lecousin.reactive.data.relational.mysql.test.MySqlStarter; 9 | import net.lecousin.reactive.data.relational.test.multipleconnections.TestMultipleDatabaseConnections; 10 | 11 | @ContextConfiguration(classes = TestMultipleConnections.MySqlDbUrls.class) 12 | public class TestMultipleConnections extends TestMultipleDatabaseConnections { 13 | 14 | @Configuration 15 | public static class MySqlDbUrls implements DbUrls { 16 | @Bean 17 | public MySqlStarter mysql() { 18 | return new MySqlStarter(com.wix.mysql.distribution.Version.v8_0_17); 19 | } 20 | 21 | @Override 22 | @Bean 23 | @Qualifier("db1Url") 24 | public String getFirstDbConnectionUrl() { 25 | return "r2dbcs:pool:mysql://auser:sa@127.0.0.1:" + MySqlStarter.getPort() + "/first"; 26 | } 27 | 28 | @Override 29 | @Bean 30 | @Qualifier("db2Url") 31 | public String getSecondDbConnectionUrl() { 32 | return "r2dbcs:pool:mysql://auser:sa@127.0.0.1:" + MySqlStarter.getPort() + "/second"; 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /mysql/src/test/java/net/lecousin/reactive/data/relational/mysql/test/v8_0_17/TestOneToMany.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.mysql.test.v8_0_17; 2 | 3 | import org.springframework.test.context.ContextConfiguration; 4 | 5 | import net.lecousin.reactive.data.relational.test.onetomanymodel.AbstractTestOneToManyModel; 6 | 7 | @ContextConfiguration(classes = { MySql_v8_0_17_TestConfiguration.class }) 8 | public class TestOneToMany extends AbstractTestOneToManyModel { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /mysql/src/test/java/net/lecousin/reactive/data/relational/mysql/test/v8_0_17/TestOneToOne.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.mysql.test.v8_0_17; 2 | 3 | import org.springframework.test.context.ContextConfiguration; 4 | 5 | import net.lecousin.reactive.data.relational.test.onetoonemodel.AbstractTestOneToOneModel; 6 | 7 | @ContextConfiguration(classes = { MySql_v8_0_17_TestConfiguration.class }) 8 | public class TestOneToOne extends AbstractTestOneToOneModel { 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /mysql/src/test/java/net/lecousin/reactive/data/relational/mysql/test/v8_0_17/TestSimple.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.mysql.test.v8_0_17; 2 | 3 | import org.springframework.test.context.ContextConfiguration; 4 | 5 | import net.lecousin.reactive.data.relational.test.simplemodel.AbstractTestSimpleModel; 6 | 7 | @ContextConfiguration(classes = { MySql_v8_0_17_TestConfiguration.class }) 8 | public class TestSimple extends AbstractTestSimpleModel { 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /mysql/src/test/java/net/lecousin/reactive/data/relational/mysql/test/v8_0_17/TestTree.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.mysql.test.v8_0_17; 2 | 3 | import org.springframework.test.context.ContextConfiguration; 4 | 5 | import net.lecousin.reactive.data.relational.test.treemodel.AbstractTestTreeModel; 6 | 7 | @ContextConfiguration(classes = { MySql_v8_0_17_TestConfiguration.class }) 8 | public class TestTree extends AbstractTestTreeModel { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /postgres/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /postgres/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | net.lecousin.reactive-data-relational.postgres 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.springframework.ide.eclipse.boot.validation.springbootbuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.m2e.core.maven2Builder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.jdt.core.javanature 26 | org.eclipse.m2e.core.maven2Nature 27 | 28 | 29 | -------------------------------------------------------------------------------- /postgres/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding//src/test/java=UTF-8 5 | encoding//src/test/resources=UTF-8 6 | encoding/=UTF-8 7 | -------------------------------------------------------------------------------- /postgres/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 3 | org.eclipse.jdt.core.compiler.compliance=11 4 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 5 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 6 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore 7 | org.eclipse.jdt.core.compiler.release=enabled 8 | org.eclipse.jdt.core.compiler.source=11 9 | -------------------------------------------------------------------------------- /postgres/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /postgres/.settings/org.sonarlint.eclipse.core.prefs: -------------------------------------------------------------------------------- 1 | autoEnabled=true 2 | eclipse.preferences.version=1 3 | idePrefixKey= 4 | projectKey=lecousin_lc-spring-data-r2dbc 5 | serverId=SonarCloud/lecousin 6 | sqPrefixKey=postgres 7 | -------------------------------------------------------------------------------- /postgres/.settings/org.springframework.ide.eclipse.prefs: -------------------------------------------------------------------------------- 1 | boot.validation.initialized=true 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /postgres/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | net.lecousin.reactive-data-relational 5 | parent 6 | 0.10.2 7 | 8 | postgres 9 | 10 | 11 | ${project.basedir}/../jacoco-report-aggregate/target/site/jacoco-aggregate/jacoco.xml 12 | 13 | 14 | 15 | 16 | ${project.groupId} 17 | core 18 | ${project.version} 19 | 20 | 21 | 22 | org.postgresql 23 | r2dbc-postgresql 24 | ${r2dbc-postgres.version} 25 | 26 | 27 | 28 | ${project.groupId} 29 | core 30 | ${project.version} 31 | test-jar 32 | test 33 | 34 | 35 | 36 | ${project.groupId} 37 | test-junit-5 38 | ${project.version} 39 | test 40 | 41 | 42 | 43 | io.zonky.test 44 | embedded-postgres 45 | 1.2.8 46 | test 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /postgres/src/main/java/net/lecousin/reactive/data/relational/postgres/PostgresConfiguration.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.postgres; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | import net.lecousin.reactive.data.relational.configuration.LcReactiveDataRelationalConfiguration; 7 | 8 | @Configuration 9 | public class PostgresConfiguration extends LcReactiveDataRelationalConfiguration { 10 | 11 | @Bean 12 | @Override 13 | public PostgresSchemaDialect schemaDialect() { 14 | return new PostgresSchemaDialect(); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /postgres/src/main/resources/META-INF/services/net.lecousin.reactive.data.relational.schema.dialect.RelationalDatabaseSchemaDialect: -------------------------------------------------------------------------------- 1 | net.lecousin.reactive.data.relational.postgres.PostgresSchemaDialect -------------------------------------------------------------------------------- /postgres/src/test/java/net/lecousin/reactive/data/relational/postgres/test/PostgresTestConfiguration.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.postgres.test; 2 | 3 | import java.io.IOException; 4 | import java.sql.Connection; 5 | import java.time.Duration; 6 | 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | 10 | import io.r2dbc.spi.ConnectionFactories; 11 | import io.r2dbc.spi.ConnectionFactory; 12 | import io.zonky.test.db.postgres.embedded.EmbeddedPostgres; 13 | import net.lecousin.reactive.data.relational.postgres.PostgresConfiguration; 14 | 15 | @Configuration 16 | public class PostgresTestConfiguration extends PostgresConfiguration { 17 | 18 | public static EmbeddedPostgres epg; 19 | private static Throwable error = null; 20 | 21 | static { 22 | Runtime.getRuntime().addShutdownHook(new Thread() { 23 | @Override 24 | public void run() { 25 | if (epg != null) 26 | try { 27 | epg.close(); 28 | } catch (IOException e) { 29 | e.printStackTrace(); 30 | } 31 | } 32 | }); 33 | EmbeddedPostgres.Builder builder = EmbeddedPostgres.builder().setPGStartupWait(Duration.ofSeconds(30)); 34 | try { 35 | epg = builder.start(); 36 | Connection conn = epg.getPostgresDatabase().getConnection(); 37 | conn.prepareCall("CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\"").execute(); 38 | conn.prepareCall("CREATE DATABASE first").execute(); 39 | conn.prepareCall("CREATE DATABASE second").execute(); 40 | conn.close(); 41 | } catch (Throwable e) { 42 | error = e; 43 | } 44 | } 45 | 46 | @Override 47 | @Bean 48 | public ConnectionFactory connectionFactory() { 49 | if (error != null) 50 | throw new RuntimeException("Postgres server not started", error); 51 | return ConnectionFactories.get("r2dbc:pool:postgresql://postgres@localhost:" + epg.getPort()); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /postgres/src/test/java/net/lecousin/reactive/data/relational/postgres/test/TestArrayColumns.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.postgres.test; 2 | 3 | import org.springframework.test.context.ContextConfiguration; 4 | 5 | import net.lecousin.reactive.data.relational.test.arraycolumns.AbstractTestArrayColumns; 6 | 7 | @ContextConfiguration(classes = { PostgresTestConfiguration.class }) 8 | public class TestArrayColumns extends AbstractTestArrayColumns { 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /postgres/src/test/java/net/lecousin/reactive/data/relational/postgres/test/TestBasic.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.postgres.test; 2 | 3 | import org.springframework.test.context.ContextConfiguration; 4 | 5 | import net.lecousin.reactive.data.relational.postgres.PostgresSchemaDialect; 6 | import net.lecousin.reactive.data.relational.schema.dialect.RelationalDatabaseSchemaDialect; 7 | import net.lecousin.reactive.data.relational.test.AbstractBasicTest; 8 | 9 | @ContextConfiguration(classes = { PostgresTestConfiguration.class }) 10 | public class TestBasic extends AbstractBasicTest { 11 | 12 | @Override 13 | protected Class expectedDialect() { 14 | return PostgresSchemaDialect.class; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /postgres/src/test/java/net/lecousin/reactive/data/relational/postgres/test/TestEnvelopeModel.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.postgres.test; 2 | 3 | import org.springframework.test.context.ContextConfiguration; 4 | 5 | import net.lecousin.reactive.data.relational.test.envelopemodel.AbstractTestEnvelopeModel; 6 | 7 | @ContextConfiguration(classes = { PostgresTestConfiguration.class }) 8 | public class TestEnvelopeModel extends AbstractTestEnvelopeModel { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /postgres/src/test/java/net/lecousin/reactive/data/relational/postgres/test/TestManyToMany.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.postgres.test; 2 | 3 | import org.springframework.test.context.ContextConfiguration; 4 | 5 | import net.lecousin.reactive.data.relational.test.manytomanymodel.AbstractTestManyToManyModel; 6 | 7 | @ContextConfiguration(classes = { PostgresTestConfiguration.class }) 8 | public class TestManyToMany extends AbstractTestManyToManyModel { 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /postgres/src/test/java/net/lecousin/reactive/data/relational/postgres/test/TestModel1.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.postgres.test; 2 | 3 | import org.springframework.test.context.ContextConfiguration; 4 | 5 | import net.lecousin.reactive.data.relational.test.model1.AbstractTestModel1; 6 | 7 | @ContextConfiguration(classes = { PostgresTestConfiguration.class }) 8 | public class TestModel1 extends AbstractTestModel1 { 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /postgres/src/test/java/net/lecousin/reactive/data/relational/postgres/test/TestMultipleConnections.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.postgres.test; 2 | 3 | import org.springframework.beans.factory.annotation.Qualifier; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.test.context.ContextConfiguration; 7 | 8 | import net.lecousin.reactive.data.relational.test.multipleconnections.TestMultipleDatabaseConnections; 9 | 10 | @ContextConfiguration(classes = TestMultipleConnections.PgDbUrls.class) 11 | public class TestMultipleConnections extends TestMultipleDatabaseConnections { 12 | 13 | @Configuration 14 | public static class PgDbUrls implements DbUrls { 15 | @Override 16 | @Bean 17 | @Qualifier("db1Url") 18 | public String getFirstDbConnectionUrl() { 19 | return "r2dbc:pool:postgresql://postgres@localhost:" + PostgresTestConfiguration.epg.getPort() + "/first"; 20 | } 21 | 22 | @Override 23 | @Bean 24 | @Qualifier("db2Url") 25 | public String getSecondDbConnectionUrl() { 26 | return "r2dbc:pool:postgresql://postgres@localhost:" + PostgresTestConfiguration.epg.getPort() + "/second"; 27 | } 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /postgres/src/test/java/net/lecousin/reactive/data/relational/postgres/test/TestOneToMany.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.postgres.test; 2 | 3 | import org.springframework.test.context.ContextConfiguration; 4 | 5 | import net.lecousin.reactive.data.relational.test.onetomanymodel.AbstractTestOneToManyModel; 6 | 7 | @ContextConfiguration(classes = { PostgresTestConfiguration.class }) 8 | public class TestOneToMany extends AbstractTestOneToManyModel { 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /postgres/src/test/java/net/lecousin/reactive/data/relational/postgres/test/TestOneToOne.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.postgres.test; 2 | 3 | import org.springframework.test.context.ContextConfiguration; 4 | 5 | import net.lecousin.reactive.data.relational.test.onetoonemodel.AbstractTestOneToOneModel; 6 | 7 | @ContextConfiguration(classes = { PostgresTestConfiguration.class }) 8 | public class TestOneToOne extends AbstractTestOneToOneModel { 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /postgres/src/test/java/net/lecousin/reactive/data/relational/postgres/test/TestSimple.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.postgres.test; 2 | 3 | import org.springframework.test.context.ContextConfiguration; 4 | 5 | import net.lecousin.reactive.data.relational.test.simplemodel.AbstractTestSimpleModel; 6 | 7 | @ContextConfiguration(classes = { PostgresTestConfiguration.class }) 8 | public class TestSimple extends AbstractTestSimpleModel { 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /postgres/src/test/java/net/lecousin/reactive/data/relational/postgres/test/TestTree.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.postgres.test; 2 | 3 | import org.springframework.test.context.ContextConfiguration; 4 | 5 | import net.lecousin.reactive.data.relational.test.treemodel.AbstractTestTreeModel; 6 | 7 | @ContextConfiguration(classes = { PostgresTestConfiguration.class }) 8 | public class TestTree extends AbstractTestTreeModel { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /postgres/src/test/java/net/lecousin/reactive/data/relational/postgres/test/geometry/PgGeometryRepository.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.postgres.test.geometry; 2 | 3 | import net.lecousin.reactive.data.relational.repository.LcR2dbcRepository; 4 | 5 | public interface PgGeometryRepository extends LcR2dbcRepository { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /postgres/src/test/resources/lc-reactive-data-relational.yaml: -------------------------------------------------------------------------------- 1 | entities: 2 | - net.lecousin.reactive.data.relational.postgres.test: 3 | - geometry: 4 | - PgGeometryEntity 5 | -------------------------------------------------------------------------------- /test-junit-5/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /test-junit-5/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | net.lecousin.reactive-data-relational.test-junit-5 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.springframework.ide.eclipse.boot.validation.springbootbuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.m2e.core.maven2Builder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.jdt.core.javanature 26 | org.eclipse.m2e.core.maven2Nature 27 | 28 | 29 | -------------------------------------------------------------------------------- /test-junit-5/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding/=UTF-8 5 | -------------------------------------------------------------------------------- /test-junit-5/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 3 | org.eclipse.jdt.core.compiler.compliance=11 4 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 5 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 6 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore 7 | org.eclipse.jdt.core.compiler.release=enabled 8 | org.eclipse.jdt.core.compiler.source=11 9 | -------------------------------------------------------------------------------- /test-junit-5/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /test-junit-5/.settings/org.sonarlint.eclipse.core.prefs: -------------------------------------------------------------------------------- 1 | autoEnabled=true 2 | eclipse.preferences.version=1 3 | idePrefixKey= 4 | projectKey=lecousin_lc-spring-data-r2dbc 5 | serverId=SonarCloud/lecousin 6 | sqPrefixKey=core 7 | -------------------------------------------------------------------------------- /test-junit-5/.settings/org.springframework.ide.eclipse.prefs: -------------------------------------------------------------------------------- 1 | boot.validation.initialized=true 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /test-junit-5/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | net.lecousin.reactive-data-relational 5 | parent 6 | 0.10.2 7 | 8 | test-junit-5 9 | 10 | 11 | 5.7.0 12 | 13 | 14 | 15 | 16 | ${project.groupId} 17 | core 18 | ${project.version} 19 | 20 | 21 | 22 | org.junit.jupiter 23 | junit-jupiter-engine 24 | ${junit-jupiter.version} 25 | 26 | 27 | -------------------------------------------------------------------------------- /test-junit-5/src/main/java/net/lecousin/reactive/data/relational/test/LcReactiveDataRelationalTestEngine.java: -------------------------------------------------------------------------------- 1 | package net.lecousin.reactive.data.relational.test; 2 | 3 | import org.junit.jupiter.engine.config.CachingJupiterConfiguration; 4 | import org.junit.jupiter.engine.config.DefaultJupiterConfiguration; 5 | import org.junit.jupiter.engine.config.JupiterConfiguration; 6 | import org.junit.jupiter.engine.descriptor.JupiterEngineDescriptor; 7 | import org.junit.platform.engine.EngineDiscoveryRequest; 8 | import org.junit.platform.engine.ExecutionRequest; 9 | import org.junit.platform.engine.TestDescriptor; 10 | import org.junit.platform.engine.TestEngine; 11 | import org.junit.platform.engine.UniqueId; 12 | 13 | import net.lecousin.reactive.data.relational.LcReactiveDataRelationalInitializer; 14 | 15 | public class LcReactiveDataRelationalTestEngine implements TestEngine { 16 | 17 | @Override 18 | public String getId() { 19 | return "net.lecousin.reactive.data.relational.engine"; 20 | } 21 | 22 | @Override 23 | public TestDescriptor discover(EngineDiscoveryRequest discoveryRequest, UniqueId uniqueId) { 24 | LcReactiveDataRelationalInitializer.init(); 25 | JupiterConfiguration configuration = new CachingJupiterConfiguration(new DefaultJupiterConfiguration(discoveryRequest.getConfigurationParameters())); 26 | return new JupiterEngineDescriptor(uniqueId, configuration); 27 | } 28 | 29 | @Override 30 | public void execute(ExecutionRequest request) { 31 | // do nothing 32 | } 33 | 34 | 35 | } 36 | -------------------------------------------------------------------------------- /test-junit-5/src/main/resources/META-INF/services/org.junit.platform.engine.TestEngine: -------------------------------------------------------------------------------- 1 | net.lecousin.reactive.data.relational.test.LcReactiveDataRelationalTestEngine -------------------------------------------------------------------------------- /test-spring-boot/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /test-spring-boot/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | net.lecousin.reactive-data-relational.test-spring-boot 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.springframework.ide.eclipse.boot.validation.springbootbuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.m2e.core.maven2Builder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.jdt.core.javanature 26 | org.eclipse.m2e.core.maven2Nature 27 | 28 | 29 | -------------------------------------------------------------------------------- /test-spring-boot/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding/=UTF-8 5 | -------------------------------------------------------------------------------- /test-spring-boot/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 3 | org.eclipse.jdt.core.compiler.compliance=11 4 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 5 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 6 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore 7 | org.eclipse.jdt.core.compiler.release=enabled 8 | org.eclipse.jdt.core.compiler.source=11 9 | -------------------------------------------------------------------------------- /test-spring-boot/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /test-spring-boot/.settings/org.springframework.ide.eclipse.prefs: -------------------------------------------------------------------------------- 1 | boot.validation.initialized=true 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /test-spring-boot/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | net.lecousin.reactive-data-relational 5 | parent 6 | 0.10.2 7 | 8 | test-spring-boot 9 | 10 | 11 | 12 | ${project.groupId} 13 | h2 14 | ${project.version} 15 | 16 | 17 | ${project.groupId} 18 | core 19 | ${project.version} 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-webflux 25 | ${spring-boot.version} 26 | 27 | 28 | 35 | 36 | 37 | 38 | 39 | 40 | org.apache.maven.plugins 41 | maven-deploy-plugin 42 | 43 | true 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /test-spring-boot/src/main/java/myapp/MyApp.java: -------------------------------------------------------------------------------- 1 | package myapp; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.ConfigurableApplicationContext; 6 | import org.springframework.context.annotation.Import; 7 | import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories; 8 | 9 | import net.lecousin.reactive.data.relational.LcReactiveDataRelationalInitializer; 10 | import net.lecousin.reactive.data.relational.h2.H2Configuration; 11 | import net.lecousin.reactive.data.relational.repository.LcR2dbcRepositoryFactoryBean; 12 | 13 | @SpringBootApplication 14 | @EnableR2dbcRepositories(repositoryFactoryBeanClass = LcR2dbcRepositoryFactoryBean.class) 15 | @Import(H2Configuration.class) 16 | public class MyApp { 17 | 18 | public static void main(String[] args) { 19 | LcReactiveDataRelationalInitializer.init(); 20 | try { 21 | ConfigurableApplicationContext app = SpringApplication.run(MyApp.class, args); 22 | if (app.getBean(MyService.class).doSomething()) 23 | System.out.println("OK"); 24 | else 25 | System.out.println("KO"); 26 | app.close(); 27 | } catch (Throwable t) { 28 | t.printStackTrace(System.err); 29 | } 30 | System.exit(0); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /test-spring-boot/src/main/java/myapp/MyRepo.java: -------------------------------------------------------------------------------- 1 | package myapp; 2 | 3 | import myapp.model.MyEntity; 4 | import net.lecousin.reactive.data.relational.repository.LcR2dbcRepository; 5 | 6 | public interface MyRepo extends LcR2dbcRepository { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /test-spring-boot/src/main/java/myapp/MyService.java: -------------------------------------------------------------------------------- 1 | package myapp; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Service; 5 | 6 | import myapp.model.MyEntity; 7 | import net.lecousin.reactive.data.relational.LcReactiveDataRelationalClient; 8 | 9 | @Service 10 | public class MyService { 11 | 12 | @Autowired 13 | private MyRepo repo; 14 | 15 | @Autowired 16 | private LcReactiveDataRelationalClient client; 17 | 18 | public boolean doSomething() { 19 | client.createSchemaContent(client.buildSchemaFromEntities()).block(); 20 | MyEntity entity = new MyEntity(); 21 | entity.setValue("Hello World !"); 22 | repo.save(entity).block(); 23 | entity = repo.findAll().blockFirst(); 24 | return entity != null && "Hello World !".equals(entity.getValue()) && entity.entityLoaded(); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /test-spring-boot/src/main/java/myapp/model/AllowEnhancer.java: -------------------------------------------------------------------------------- 1 | package myapp.model; 2 | 3 | public interface AllowEnhancer { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /test-spring-boot/src/main/java/myapp/model/MyEntity.java: -------------------------------------------------------------------------------- 1 | package myapp.model; 2 | 3 | import org.springframework.data.annotation.Id; 4 | import org.springframework.data.relational.core.mapping.Column; 5 | import org.springframework.data.relational.core.mapping.Table; 6 | 7 | import net.lecousin.reactive.data.relational.annotations.GeneratedValue; 8 | 9 | @Table 10 | public class MyEntity { 11 | 12 | @Id @GeneratedValue 13 | private Long id; 14 | 15 | @Column("value") 16 | private String value; 17 | 18 | public Long getId() { 19 | return id; 20 | } 21 | 22 | public void setId(Long id) { 23 | this.id = id; 24 | } 25 | 26 | public String getValue() { 27 | return value; 28 | } 29 | 30 | public void setValue(String value) { 31 | this.value = value; 32 | } 33 | 34 | public boolean entityLoaded() { 35 | return false; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /test-spring-boot/src/main/resources/META-INF/spring-devtools.properties: -------------------------------------------------------------------------------- 1 | restart.exclude.companycommonlibs=.*core.* -------------------------------------------------------------------------------- /test-spring-boot/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | r2dbc: 3 | username: sa 4 | url: r2dbc:h2:mem:///testdb;DB_CLOSE_DELAY=-1; -------------------------------------------------------------------------------- /test-spring-boot/src/main/resources/lc-reactive-data-relational.yaml: -------------------------------------------------------------------------------- 1 | entities: 2 | - myapp.model: 3 | - MyEntity 4 | --------------------------------------------------------------------------------