Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: [SpringBoot 2.3] Couchbase: Update to Spring Data Couchbase 4.0 and Couchbase SDK 3 #11845

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions generators/cleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,13 @@ function cleanupOldServerFiles(generator, javaDir, testDir, mainResourceDir, tes
if (generator.searchEngine === 'elasticsearch') {
generator.removeFile(`${testDir}config/ElasticsearchTestConfiguration.java`);
}
if (generator.databaseType === 'couchbase') {
generator.removeFile(`${javaDir}repository/N1qlCouchbaseRepository.java`);
generator.removeFile(`${testDir}config/DatabaseConfigurationIT.java`);
if (generator.searchEngine !== 'couchbase') {
generator.removeFile(`${javaDir}repository/CustomN1qlCouchbaseRepository.java`);
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ import org.springframework.data.couchbase.core.mapping.Document;
import org.springframework.data.couchbase.core.mapping.id.GeneratedValue;
import org.springframework.data.couchbase.core.mapping.id.IdPrefix;
<%_ } _%>
import com.couchbase.client.java.repository.annotation.Field;
import org.springframework.data.couchbase.core.mapping.Field;
<%_ if (hasRelationship) { _%>
import org.springframework.data.couchbase.core.query.FetchType;
import org.springframework.data.couchbase.core.query.N1qlJoin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import org.springframework.data.cassandra.repository.ReactiveCassandraRepository
import <%= packageName %>.repository.search.SearchCouchbaseRepository;
<%_ } _%>
<%_ if (databaseType === 'couchbase') { _%>
import org.springframework.data.couchbase.core.query.Query;
import org.springframework.data.couchbase.repository.ReactiveCouchbaseSortingRepository;
import org.springframework.data.couchbase.repository.Query;
import org.springframework.data.couchbase.repository.ReactiveCouchbaseRepository;
<%_ } _%>
<%_ if (databaseType === 'neo4j') { _%>
import org.neo4j.springframework.data.repository.ReactiveNeo4jRepository;
Expand Down Expand Up @@ -59,7 +59,7 @@ import java.util.UUID;
*/
@SuppressWarnings("unused")
@Repository
public interface <%= entityClass %>Repository extends Reactive<% if (databaseType === 'mongodb') { %>Mongo<% } if (databaseType === 'couchbase') { %>N1qlCouchbase<% } if (databaseType === 'neo4j') { %>Neo4j<% } if (databaseType === 'cassandra') { %>Cassandra<% } %>Repository<<%= asEntity(entityClass) %>, <%= primaryKeyType %>><% if (searchEngine === 'couchbase') { %>, SearchCouchbaseRepository<<%= asEntity(entityClass) %>, <%= primaryKeyType %>><% } %> {
public interface <%= entityClass %>Repository extends Reactive<% if (databaseType === 'mongodb') { %>Mongo<% } if (databaseType === 'couchbase') { %>Couchbase<% } if (databaseType === 'neo4j') { %>Neo4j<% } if (databaseType === 'cassandra') { %>Cassandra<% } %>Repository<<%= asEntity(entityClass) %>, <%= primaryKeyType %>><% if (searchEngine === 'couchbase') { %>, SearchCouchbaseRepository<<%= asEntity(entityClass) %>, <%= primaryKeyType %>><% } %> {

<%_ if (pagination !== 'no') { _%>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ import org.springframework.data.jpa.repository.*;
<%_ if (fieldsContainOwnerManyToMany) { _%>
import org.springframework.data.repository.query.Param;
<%_ } _%>
<%_ } _%>
<%_ if (databaseType === 'mongodb') { _%>
<%_ } else if (databaseType === 'mongodb') { _%>
import org.springframework.data.mongodb.repository.Query;
import org.springframework.data.mongodb.repository.MongoRepository;
<%_ } _%>
<%_ if (databaseType === 'neo4j') { _%>
<%_ } else if (databaseType === 'neo4j') { _%>
import org.neo4j.springframework.data.repository.Neo4jRepository;
import org.neo4j.springframework.data.repository.query.Query;
import java.util.List;
<%_ } else if (databaseType === 'couchbase') { _%>
import org.springframework.data.couchbase.repository.CouchbaseRepository;
<%_ } _%>
<%_ if (searchEngine === 'couchbase') { _%>
import <%= packageName %>.repository.search.SearchCouchbaseRepository;
Expand Down Expand Up @@ -80,7 +80,7 @@ import java.util.UUID;
@SuppressWarnings("unused")
<%_ } _%>
@Repository
public interface <%= entityClass %>Repository extends <% if (databaseType === 'sql') { %>JpaRepository<% } %><% if (databaseType === 'mongodb') { %>MongoRepository<% } %><% if (databaseType === 'neo4j') { %>Neo4jRepository<% } %><% if (databaseType === 'cassandra') { %>CassandraRepository<% } %><% if (databaseType === 'couchbase') { %>N1qlCouchbaseRepository<% } %><<%= asEntity(entityClass) %>, <%= primaryKeyType %>><% if (jpaMetamodelFiltering) { %>, JpaSpecificationExecutor<<%= asEntity(entityClass) %>><% } %><% if (searchEngine === 'couchbase') { %>, SearchCouchbaseRepository<<%= asEntity(entityClass) %>, <%= primaryKeyType %>><% } %> {
public interface <%= entityClass %>Repository extends <% if (databaseType === 'sql') { %>JpaRepository<% } %><% if (databaseType === 'mongodb') { %>MongoRepository<% } %><% if (databaseType === 'neo4j') { %>Neo4jRepository<% } %><% if (databaseType === 'cassandra') { %>CassandraRepository<% } %><% if (databaseType === 'couchbase') { %>CouchbaseRepository<% } %><<%= asEntity(entityClass) %>, <%= primaryKeyType %>><% if (jpaMetamodelFiltering) { %>, JpaSpecificationExecutor<<%= asEntity(entityClass) %>><% } %><% if (searchEngine === 'couchbase') { %>, SearchCouchbaseRepository<<%= asEntity(entityClass) %>, <%= primaryKeyType %>><% } %> {
<%_ for (idx in relationships) {
if (relationships[idx].relationshipType === 'many-to-one' && relationships[idx].otherEntityName === 'user' && databaseType === 'sql') { _%>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ if (databaseType === 'sql' && !reactive) {
_%>
<%_ if (databaseType === 'cassandra') { _%>
import <%= packageName %>.AbstractCassandraTest;
<%_ } _%>
<%_ if (databaseType === 'neo4j') { _%>
<%_ } else if (databaseType === 'couchbase') { _%>
import <%= packageName %>.CouchbaseTestContainerExtension;
<%_ } else if (databaseType === 'neo4j') { _%>
import <%= packageName %>.AbstractNeo4jIT;
<%_ } _%>
<%_ if (cacheProvider === 'redis') { _%>
Expand Down Expand Up @@ -115,7 +116,7 @@ import org.mockito.Mock;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
<%_ } _%>
<%_ if (databaseType === 'neo4j') { _%>
<%_ if (['neo4j', 'couchbase'].includes(databaseType)) { _%>
import org.junit.jupiter.api.extension.ExtendWith;
<%_ } _%>
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -216,7 +217,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
<%_ } else if (searchEngine === 'elasticsearch' || fieldsContainOwnerManyToMany === true) { _%>
@ExtendWith(MockitoExtension.class)
<%_ } _%>
<%_ if (databaseType === 'neo4j') { _%>
<%_ if (databaseType === 'couchbase') { _%>
@ExtendWith(CouchbaseTestContainerExtension.class)
<%_ } else if (databaseType === 'neo4j') { _%>
@ExtendWith(AbstractNeo4jIT.class)
<%_ } _%>
<%_ if (!reactive) { _%>
Expand Down
40 changes: 21 additions & 19 deletions generators/server/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -990,21 +990,13 @@ const serverFiles = {
],
},
{
condition: generator =>
generator.databaseType === 'sql' ||
generator.databaseType === 'mongodb' ||
generator.databaseType === 'neo4j' ||
generator.databaseType === 'couchbase',
condition: generator => ['sql', 'mongodb', 'neo4j', 'couchbase'].includes(generator.databaseType),
path: SERVER_MAIN_SRC_DIR,
templates: [
{
file: 'package/config/CloudDatabaseConfiguration.java',
renameTo: generator => `${generator.javaDir}config/CloudDatabaseConfiguration.java`,
},
{
file: 'package/config/DatabaseConfiguration.java',
renameTo: generator => `${generator.javaDir}config/DatabaseConfiguration.java`,
},
{
file: 'package/config/audit/package-info.java',
renameTo: generator => `${generator.javaDir}config/audit/package-info.java`,
Expand All @@ -1016,33 +1008,43 @@ const serverFiles = {
],
},
{
condition: generator => generator.databaseType === 'sql',
condition: generator => ['sql', 'mongodb', 'neo4j'].includes(generator.databaseType),
path: SERVER_MAIN_SRC_DIR,
templates: [
{
file: 'package/config/LiquibaseConfiguration.java',
renameTo: generator => `${generator.javaDir}config/LiquibaseConfiguration.java`,
file: 'package/config/DatabaseConfiguration.java',
renameTo: generator => `${generator.javaDir}config/DatabaseConfiguration.java`,
},
],
},
{
condition: generator => !generator.reactive && generator.databaseType === 'couchbase',
condition: generator => generator.databaseType === 'couchbase',
path: SERVER_MAIN_SRC_DIR,
templates: [
{
file: 'package/repository/N1qlCouchbaseRepository.java',
renameTo: generator => `${generator.javaDir}repository/N1qlCouchbaseRepository.java`,
file: 'package/config/database/CouchbaseDatabaseConfiguration.java',
renameTo: generator => `${generator.javaDir}config/DatabaseConfiguration.java`,
},
],
},
{
condition: generator => generator.databaseType === 'sql',
path: SERVER_MAIN_SRC_DIR,
templates: [
{
file: 'package/repository/CustomN1qlCouchbaseRepository.java',
renameTo: generator => `${generator.javaDir}repository/CustomN1qlCouchbaseRepository.java`,
file: 'package/config/LiquibaseConfiguration.java',
renameTo: generator => `${generator.javaDir}config/LiquibaseConfiguration.java`,
},
],
},
{
condition: generator => generator.searchEngine === 'couchbase',
path: SERVER_MAIN_SRC_DIR,
templates: [
{
file: 'package/repository/CustomN1qlCouchbaseRepository.java',
renameTo: generator => `${generator.javaDir}repository/CustomN1qlCouchbaseRepository.java`,
},
{
file: 'package/repository/search/SearchCouchbaseRepository.java',
renameTo: generator => `${generator.javaDir}repository/search/SearchCouchbaseRepository.java`,
Expand Down Expand Up @@ -1318,8 +1320,8 @@ const serverFiles = {
path: SERVER_TEST_SRC_DIR,
templates: [
{
file: 'package/config/DatabaseConfigurationIT.java',
renameTo: generator => `${generator.testDir}config/DatabaseConfigurationIT.java`,
file: 'package/CouchbaseTestContainerExtension.java',
renameTo: generator => `${generator.testDir}CouchbaseTestContainerExtension.java`,
},
],
},
Expand Down
8 changes: 8 additions & 0 deletions generators/server/templates/build.gradle.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ repositories {
mavenLocal()
mavenCentral()
jcenter()
<%_ if (databaseType === 'couchbase') { _%>
// FIXME: remove once spring-data-couchbase 4.0.2 is released with DATACOUCH-546 and DATACOUCH-576 fixes
maven { url 'https://repo.spring.io/milestone' }
<%_ } _%>
<%_ if (!SPRING_BOOT_VERSION.endsWith('RELEASE')) { _%>
maven { url 'https://repo.spring.io/milestone' }
<%_ } _%>
Expand Down Expand Up @@ -403,6 +407,10 @@ dependencies {
<%_ if (searchEngine === 'elasticsearch') { _%>
implementation "org.springframework.boot:spring-boot-starter-data-elasticsearch"
<%_ } _%>
<%_ if (databaseType === 'couchbase') { _%>
// FIXME: remove once spring-data-couchbase 4.0.2 is released with DATACOUCH-546 and DATACOUCH-576 fixes
implementation "org.springframework.data:spring-data-couchbase:4.1.0-M1"
<%_ } _%>
<%_ if (['mongodb', 'cassandra', 'couchbase'].includes(databaseType)) { _%>
implementation "org.springframework.boot:spring-boot-starter-data-<%= databaseType %><% if (reactive) { %>-reactive<% } %>"
<%_ } _%>
Expand Down
28 changes: 24 additions & 4 deletions generators/server/templates/pom.xml.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@
</snapshots>
</repository>
<%_ } _%>
<%_ if (databaseType === 'couchbase') { _%>
<!-- FIXME: remove once spring-data-couchbase 4.0.2 is released with DATACOUCH-546 and DATACOUCH-576 fixes -->
<repository>
<id>spring-milestone</id>
<url>https://repo.spring.io/milestone</url>
</repository>
<%_ } _%>
<%_ if (!SPRING_BOOT_VERSION.endsWith('RELEASE')) { _%>
<repository>
<id>spring-milestone</id>
Expand Down Expand Up @@ -402,10 +409,6 @@
<groupId>com.couchbase.client</groupId>
<artifactId>java-client</artifactId>
</dependency>
<dependency>
<groupId>com.couchbase.client</groupId>
<artifactId>encryption</artifactId>
</dependency>
<%_ } _%>
<%_ if (databaseType === 'neo4j') { _%>
<dependency>
Expand Down Expand Up @@ -646,10 +649,27 @@
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<%_ } _%>
<%_ if (databaseType === 'couchbase') { _%>
<!-- FIXME: remove once spring-data-couchbase 4.0.2 is released with DATACOUCH-546 and DATACOUCH-576 fixes -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-couchbase</artifactId>
<version>4.1.0-M1</version>
</dependency>
<%_ } _%>
<%_ if (['mongodb', 'cassandra', 'couchbase'].includes(databaseType)) { _%>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-<%= databaseType %><% if (reactive) { %>-reactive<% } %></artifactId>
<%_ if (databaseType === 'couchbase') { _%>
<!-- FIXME: remove once spring-data-couchbase 4.0.2 is released with DATACOUCH-546 and DATACOUCH-576 fixes -->
<exclusions>
<exclusion>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-couchbase</artifactId>
</exclusion>
</exclusions>
<%_ } _%>
</dependency>
<%_ } _%>
<%_ if (reactive) { _%>
Expand Down
Loading