generator-jhipster 7.7.0 → 7.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -2
- package/generators/app/index.js +10 -0
- package/generators/ci-cd/index.js +1 -1
- package/generators/ci-cd/templates/github-actions.yml.ejs +4 -4
- package/generators/client/files-common.js +1 -2
- package/generators/client/files-react.js +25 -2
- package/generators/client/index.js +1 -1
- package/generators/client/needle-api/needle-client-react.js +11 -8
- package/generators/client/templates/angular/angular.json.ejs +1 -9
- package/generators/client/templates/angular/jest.conf.js.ejs +1 -1
- package/generators/client/templates/angular/package.json +17 -18
- package/generators/client/templates/angular/package.json.ejs +1 -1
- package/generators/client/templates/angular/src/main/webapp/app/admin/user-management/list/user-management.component.ts.ejs +1 -1
- package/generators/client/templates/angular/src/main/webapp/app/core/util/data-util.service.ts.ejs +1 -1
- package/generators/client/templates/angular/src/main/webapp/app/core/util/parse-links.service.ts.ejs +1 -1
- package/generators/client/templates/angular/webpack/webpack.custom.js.ejs +12 -1
- package/generators/client/templates/common/package.json +7 -6
- package/generators/client/templates/common/webpack/webpack.microfrontend.js.jhi.ejs +2 -3
- package/generators/client/templates/react/.eslintrc.json.ejs +1 -1
- package/generators/client/templates/react/jest.conf.js.ejs +1 -1
- package/generators/client/templates/react/package.json +30 -31
- package/generators/client/templates/react/package.json.ejs +1 -0
- package/generators/client/templates/react/src/main/webapp/app/app.scss.ejs +1 -1
- package/generators/client/templates/react/src/main/webapp/app/config/store.ts.ejs +53 -6
- package/generators/client/templates/react/src/main/webapp/app/config/translation-middleware.ts.ejs +58 -0
- package/generators/client/templates/react/src/main/webapp/app/entities/menu.tsx.ejs +45 -0
- package/generators/client/templates/react/src/main/webapp/app/entities/reducers.ts.ejs +25 -0
- package/generators/client/templates/react/src/main/webapp/app/entities/routes.tsx.ejs +47 -0
- package/generators/client/templates/react/src/main/webapp/app/index.tsx.ejs +7 -7
- package/generators/client/templates/react/src/main/webapp/app/main.tsx.ejs +19 -0
- package/generators/client/templates/react/src/main/webapp/app/modules/administration/logs/logs.tsx.ejs +1 -1
- package/generators/client/templates/react/src/main/webapp/app/modules/administration/user-management/user-management.tsx.ejs +2 -1
- package/generators/client/templates/react/src/main/webapp/app/modules/login/login-modal.tsx.ejs +5 -1
- package/generators/client/templates/react/src/main/webapp/app/routes.tsx.ejs +24 -7
- package/generators/client/templates/react/src/main/webapp/app/shared/error/error-loading.tsx.ejs +15 -0
- package/generators/client/templates/react/src/main/webapp/app/shared/layout/menus/entities.tsx.ejs +34 -6
- package/generators/client/templates/react/src/main/webapp/app/shared/reducers/index.ts.ejs +9 -2
- package/generators/client/templates/react/src/main/webapp/app/shared/reducers/locale.spec.ts.ejs +9 -3
- package/generators/client/templates/react/src/main/webapp/app/shared/reducers/locale.ts.ejs +21 -5
- package/generators/client/templates/react/src/main/webapp/app/typings.d.ts.ejs +15 -0
- package/generators/client/templates/react/src/main/webapp/microfrontends/entities-menu.tsx.ejs +3 -0
- package/generators/client/templates/react/src/main/webapp/microfrontends/entities-routes.tsx.ejs +3 -0
- package/generators/client/templates/react/tsconfig.json.ejs +3 -3
- package/generators/client/templates/react/tsconfig.test.json.ejs +9 -1
- package/generators/client/templates/react/webpack/webpack.common.js.ejs +6 -13
- package/generators/client/templates/react/webpack/webpack.dev.js.ejs +7 -8
- package/generators/client/templates/react/webpack/webpack.microfrontend.js.jhi.react.ejs +99 -0
- package/generators/client/templates/react/webpack/webpack.prod.js.ejs +31 -21
- package/generators/client/templates/vue/package.json +16 -17
- package/generators/client/templates/vue/package.json.ejs +1 -1
- package/generators/client/templates/vue/src/main/webapp/app/core/jhi-navbar/jhi-navbar.component.ts.ejs +1 -0
- package/generators/client/templates/vue/src/main/webapp/app/shared/data/data-utils.service.ts.ejs +1 -1
- package/generators/client/templates/vue/src/test/javascript/jest.conf.js.ejs +2 -2
- package/generators/client/templates/vue/tsconfig.json.ejs +0 -3
- package/generators/client/templates/vue/webpack/webpack.common.js.ejs +6 -2
- package/generators/common/templates/package.json +2 -2
- package/generators/docker-compose/index.js +9 -5
- package/generators/entity/index.js +34 -19
- package/generators/entity-client/index.js +8 -0
- package/generators/entity-client/templates/angular/src/main/webapp/app/entities/list/entity-management.component.ts.ejs +1 -1
- package/generators/entity-client/templates/angular/src/main/webapp/app/entities/update/entity-management-update.component.ts.ejs +1 -1
- package/generators/entity-client/templates/common/src/test/javascript/cypress/integration/entity/entity.spec.ts.ejs +1 -0
- package/generators/entity-client/templates/react/src/main/webapp/app/entities/entity-delete-dialog.tsx.ejs +3 -3
- package/generators/entity-client/templates/react/src/main/webapp/app/entities/entity-detail.tsx.ejs +5 -4
- package/generators/entity-client/templates/react/src/main/webapp/app/entities/entity-update.tsx.ejs +19 -18
- package/generators/entity-client/templates/react/src/main/webapp/app/entities/entity.reducer.ts.ejs +2 -2
- package/generators/entity-client/templates/react/src/main/webapp/app/entities/entity.tsx.ejs +21 -20
- package/generators/entity-i18n/templates/i18n/entity_fr.json.ejs +1 -1
- package/generators/entity-server/files.js +30 -10
- package/generators/entity-server/index.js +19 -1
- package/generators/entity-server/templates/couchbase/src/main/java/package/domain/Entity.java.jhi.spring_data_couchbase.ejs +1 -1
- package/generators/entity-server/templates/couchbase/src/main/java/package/repository/EntityRepository.java.ejs +31 -8
- package/generators/entity-server/templates/partials/update_template.ejs +77 -0
- package/generators/entity-server/templates/reactive/partials/save_template.ejs +1 -1
- package/generators/entity-server/templates/reactive/partials/update_template.ejs +41 -0
- package/generators/entity-server/templates/src/main/java/package/common/get_all_template.ejs +5 -5
- package/generators/entity-server/templates/src/main/java/package/common/get_template.ejs +1 -1
- package/generators/entity-server/templates/src/main/java/package/common/inject_template.ejs +13 -4
- package/generators/entity-server/templates/src/main/java/package/common/patch_template.ejs +2 -2
- package/generators/entity-server/templates/src/main/java/package/domain/Entity.java.jhi.ejs +2 -1
- package/generators/entity-server/templates/src/main/java/package/domain/Entity.java.jhi.javax_lifecycle_events.ejs +31 -0
- package/generators/entity-server/templates/src/main/java/package/domain/Entity.java.jhi.spring_data_persistable.ejs +54 -0
- package/generators/entity-server/templates/src/main/java/package/domain/Entity.java.jhi.spring_data_reactive.ejs +1 -1
- package/generators/entity-server/templates/src/main/java/package/domain/EntityCallback.java.ejs +43 -0
- package/generators/entity-server/templates/src/main/java/package/repository/EntityRepository.java.ejs +6 -6
- package/generators/entity-server/templates/src/main/java/package/repository/EntityRepositoryInternalImpl_reactive.java.ejs +13 -16
- package/generators/entity-server/templates/src/main/java/package/repository/EntityRepositoryWithBagRelationshipsImpl.java.ejs +4 -3
- package/generators/entity-server/templates/src/main/java/package/repository/EntityRepository_reactive.java.ejs +15 -23
- package/generators/entity-server/templates/src/main/java/package/repository/EntitySqlHelper_reactive.java.ejs +2 -2
- package/generators/entity-server/templates/src/main/java/package/repository/rowmapper/EntityRowMapper.java.ejs +2 -2
- package/generators/entity-server/templates/src/main/java/package/repository/search/EntitySearchRepository.java.ejs +12 -25
- package/generators/entity-server/templates/src/main/java/package/service/EntityService.java.ejs +10 -2
- package/generators/entity-server/templates/src/main/java/package/service/impl/EntityServiceImpl.java.ejs +21 -5
- package/generators/entity-server/templates/src/main/java/package/service/mapper/EntityMapper.java.ejs +61 -90
- package/generators/entity-server/templates/src/main/java/package/web/rest/EntityResource.java.ejs +6 -4
- package/generators/entity-server/templates/src/test/java/package/web/rest/EntityResourceIT.java.ejs +28 -15
- package/generators/generator-base-private.js +1 -1
- package/generators/generator-base.js +29 -0
- package/generators/generator-constants.js +5 -5
- package/generators/generator-transforms.js +0 -1
- package/generators/gradle/constants.cjs +1 -1
- package/generators/maven/files.cjs +0 -1
- package/generators/maven/templates/.mvn/wrapper/maven-wrapper.jar +0 -0
- package/generators/maven/templates/.mvn/wrapper/maven-wrapper.properties +18 -2
- package/generators/maven/templates/mvnw +13 -7
- package/generators/maven/templates/mvnw.cmd +19 -13
- package/generators/maven/templates/pom.xml.jhi.ejs +1 -1
- package/generators/server/cleanup.js +19 -3
- package/generators/server/files.js +101 -17
- package/generators/server/index.js +11 -5
- package/generators/server/needle-api/needle-server-gradle.js +38 -0
- package/generators/server/templates/.mvn/jvm.config +1 -0
- package/generators/server/templates/.mvn/wrapper/maven-wrapper.jar +0 -0
- package/generators/server/templates/.mvn/wrapper/maven-wrapper.properties +18 -2
- package/generators/server/templates/build.gradle.ejs +7 -5
- package/generators/server/templates/couchbase/src/main/java/package/repository/JHipsterCouchbaseRepository.java.ejs +24 -1
- package/generators/server/templates/devcontainer/Dockerfile.ejs +25 -0
- package/generators/server/templates/devcontainer/devcontainer.json.ejs +64 -0
- package/generators/server/templates/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/generators/server/templates/gradle.properties.ejs +4 -4
- package/generators/server/templates/mvnw +13 -7
- package/generators/server/templates/mvnw.cmd +19 -13
- package/generators/server/templates/pom.xml.ejs +19 -17
- package/generators/server/templates/settings.gradle.ejs +6 -4
- package/generators/server/templates/src/main/docker/app.yml.ejs +2 -6
- package/generators/server/templates/src/main/docker/config/realm-config/jhipster-realm.json.ejs +2 -1
- package/generators/server/templates/src/main/docker/mysql.yml.ejs +1 -0
- package/generators/server/templates/src/main/java/package/config/AsyncConfiguration.java.ejs +6 -0
- package/generators/{client/templates/react/src/main/webapp/app/entities/index.tsx.ejs → server/templates/src/main/java/package/config/KafkaSseConsumer.java.ejs} +8 -14
- package/generators/server/templates/src/main/java/package/config/KafkaSseProducer.java.ejs +30 -0
- package/generators/server/templates/src/main/java/package/config/SecurityConfiguration.java.ejs +12 -10
- package/generators/server/templates/src/main/java/package/repository/EntityManager.java.ejs +3 -3
- package/generators/server/templates/src/main/java/package/security/jwt/JWTFilter.java.ejs +1 -1
- package/generators/server/templates/src/main/java/package/security/jwt/TokenProvider.java.ejs +1 -1
- package/generators/server/templates/src/main/java/package/web/rest/KafkaResource.java.ejs +60 -108
- package/generators/server/templates/src/main/java/package/web/rest/KafkaResource_reactive.java.ejs +74 -0
- package/generators/server/templates/src/main/resources/config/application.yml.ejs +26 -22
- package/generators/server/templates/src/test/java/package/CassandraKeyspaceIT.java.ejs +3 -4
- package/generators/server/templates/src/test/java/package/IntegrationTest.java.ejs +9 -3
- package/generators/server/templates/src/test/java/package/TechnicalStructureTest.java.ejs +0 -3
- package/generators/server/templates/src/test/java/package/config/CassandraTestContainer.java.ejs +122 -0
- package/generators/server/templates/src/test/java/package/config/EmbeddedCassandra.java.ejs +11 -0
- package/generators/server/templates/src/test/java/package/config/EmbeddedKafka.java.ejs +11 -0
- package/generators/server/templates/src/test/java/package/config/EmbeddedMongo.java.ejs +11 -0
- package/generators/server/templates/src/test/java/package/config/KafkaTestContainer.java.ejs +38 -0
- package/generators/server/templates/src/test/java/package/config/MongoDbTestContainer.java.ejs +67 -0
- package/generators/server/templates/src/test/java/package/config/TestContainersSpringContextCustomizerFactory.java.ejs +114 -0
- package/generators/server/templates/src/test/java/package/cucumber/CucumberIT.java.ejs +3 -10
- package/generators/server/templates/src/test/java/package/security/DomainUserDetailsServiceIT.java.ejs +1 -4
- package/generators/server/templates/src/test/java/package/security/jwt/JWTFilterTest.java.ejs +5 -5
- package/generators/server/templates/src/test/java/package/service/MailServiceIT.java.ejs +2 -4
- package/generators/server/templates/src/test/java/package/service/UserServiceIT.java.ejs +1 -4
- package/generators/server/templates/src/test/java/package/web/rest/AccountResourceIT.java.ejs +3 -3
- package/generators/server/templates/src/test/java/package/web/rest/AccountResourceIT_oauth2.java.ejs +1 -4
- package/generators/server/templates/src/test/java/package/web/rest/AccountResourceIT_skipUserManagement.java.ejs +1 -4
- package/generators/server/templates/src/test/java/package/web/rest/KafkaResourceIT.java.ejs +52 -123
- package/generators/server/templates/src/test/java/package/web/rest/KafkaResourceIT_reactive.java.ejs +99 -0
- package/generators/server/templates/src/test/java/package/web/rest/PublicUserResourceIT.java.ejs +7 -10
- package/generators/server/templates/src/test/java/package/web/rest/UserJWTControllerIT.java.ejs +1 -4
- package/generators/server/templates/src/test/java/package/web/rest/UserResourceIT.java.ejs +2 -5
- package/generators/server/templates/src/test/java/package/web/rest/errors/ExceptionTranslatorIT.java.ejs +1 -4
- package/generators/server/templates/src/test/java/package/web/rest/errors/ExceptionTranslatorIT_reactive.java.ejs +1 -4
- package/generators/server/templates/src/test/resources/META-INF/spring.factories.ejs +1 -1
- package/generators/server/templates/src/test/resources/config/application.yml.ejs +21 -20
- package/generators/server/templates/src/test/resources/testcontainers.properties.ejs +1 -0
- package/generators/workspaces/index.js +2 -1
- package/package.json +15 -15
- package/utils/entity.js +2 -0
- package/utils/field.js +8 -3
- package/utils/relationship.js +10 -1
- package/generators/entity-server/templates/src/main/java/package/repository/search/SortToSortBuilderListConverter.java.ejs +0 -25
- package/generators/maven/templates/.mvn/wrapper/MavenWrapperDownloader.java +0 -117
- package/generators/server/templates/.mvn/wrapper/MavenWrapperDownloader.java +0 -117
- package/generators/server/templates/src/main/java/package/config/KafkaProperties.java.ejs +0 -68
- package/generators/server/templates/src/test/java/package/AbstractCassandraTest.java.ejs +0 -125
- package/generators/server/templates/src/test/java/package/MongoDbTestContainerExtension.java.ejs +0 -37
- package/generators/server/templates/src/test/java/package/TestContainersSpringContextCustomizerFactory.java.ejs +0 -24
package/generators/entity-server/templates/src/main/java/package/common/get_all_template.ejs
CHANGED
|
@@ -50,22 +50,22 @@ _%>
|
|
|
50
50
|
}
|
|
51
51
|
<%_ } else { _%>
|
|
52
52
|
<%_ if (paginationNo) { _%>
|
|
53
|
-
public <% if (reactive) { %>Mono<<% } %>List<<%= instanceType %>><% if (reactive) { %>><% } %> getAll<%= entityClassPlural %>(<% if (fieldsContainNoOwnerOneToOne) { %>@RequestParam(required = false) String filter<% } %><% if (
|
|
53
|
+
public <% if (reactive) { %>Mono<<% } %>List<<%= instanceType %>><% if (reactive) { %>><% } %> getAll<%= entityClassPlural %>(<% if (fieldsContainNoOwnerOneToOne) { %>@RequestParam(required = false) String filter<% } %><% if (implementsEagerLoadApis && fieldsContainNoOwnerOneToOne) { %>,<% } %><% if (implementsEagerLoadApis) { %>@RequestParam(required = false, defaultValue = "false") boolean eagerload<% } %>) {<%- include('get_all_stream_template', {viaService: viaService}); -%>
|
|
54
54
|
log.debug("REST request to get all <%= entityClassPlural %>");
|
|
55
55
|
<%_ if (viaService) { _%>
|
|
56
56
|
return <%= entityInstance %>Service.findAll()<% if (reactive) { %>.collectList()<% } %>;
|
|
57
57
|
<%_ } else if (dtoMapstruct) { _%>
|
|
58
|
-
<%= reactive ? 'Flux' : 'List' %><<%= persistClass %>> <%= entityInstancePlural %> = <%= entityInstance %>Repository.<% if (
|
|
58
|
+
<%= reactive ? 'Flux' : 'List' %><<%= persistClass %>> <%= entityInstancePlural %> = <%= entityInstance %>Repository.<% if (implementsEagerLoadApis) { %>findAllWithEagerRelationships<% } else { %>findAll<% } %>();
|
|
59
59
|
<%_ if (reactive) { _%>
|
|
60
60
|
return <%= entityInstancePlural %>.map(<%= entityToDtoReference %>).collectList();
|
|
61
61
|
<%_ } else { _%>
|
|
62
62
|
return <%= entityListToDtoListReference %>(<%= entityInstancePlural %>);
|
|
63
63
|
<%_ } _%>
|
|
64
64
|
<%_ } else { _%>
|
|
65
|
-
return <%= entityInstance %>Repository.<% if (
|
|
65
|
+
return <%= entityInstance %>Repository.<% if (implementsEagerLoadApis) { %>findAllWithEagerRelationships<% } else { %>findAll<% } %>()<% if (reactive) { %>.collectList()<% } %>;
|
|
66
66
|
<%_ } _%>
|
|
67
67
|
<%_ } else { _%>
|
|
68
|
-
public <% if (reactive) { %>Mono<ResponseEntity<List<<%= instanceType %>>>><% } else { %>ResponseEntity<List<<%= instanceType %>>><% } %> getAll<%= entityClassPlural %>(@org.springdoc.api.annotations.ParameterObject Pageable pageable<% if (reactive) { %>, ServerHttpRequest request<% } %><% if (fieldsContainNoOwnerOneToOne) { %>, @RequestParam(required = false) String filter<% } %><% if (
|
|
68
|
+
public <% if (reactive) { %>Mono<ResponseEntity<List<<%= instanceType %>>>><% } else { %>ResponseEntity<List<<%= instanceType %>>><% } %> getAll<%= entityClassPlural %>(@org.springdoc.api.annotations.ParameterObject Pageable pageable<% if (reactive) { %>, ServerHttpRequest request<% } %><% if (fieldsContainNoOwnerOneToOne) { %>, @RequestParam(required = false) String filter<% } %><% if (implementsEagerLoadApis) { %>, @RequestParam(required = false, defaultValue = "true") boolean eagerload<% } %>) {<%- include('get_all_stream_template', {viaService: viaService}); -%>
|
|
69
69
|
log.debug("REST request to get a page of <%= entityClassPlural %>");
|
|
70
70
|
<%_ if (reactive) { _%>
|
|
71
71
|
return <%= entityInstance %><%= viaService ? 'Service.countAll' : 'Repository.count' %>().zipWith(<%= entityInstance %><%= viaService ? 'Service.findAll' : 'Repository.findAllBy' %>(pageable)<%= reactiveEntityToDto %>.collectList())
|
|
@@ -79,7 +79,7 @@ _%>
|
|
|
79
79
|
).body(countWithEntities.getT2())
|
|
80
80
|
);
|
|
81
81
|
<%_ } else { _%>
|
|
82
|
-
<%_ if (
|
|
82
|
+
<%_ if (implementsEagerLoadApis) { _%>
|
|
83
83
|
Page<<%= instanceType %>> page;
|
|
84
84
|
if (eagerload) {
|
|
85
85
|
page = <%= entityInstance %><%= viaService ? 'Service' : 'Repository' %>.findAllWithEagerRelationships(pageable)<%= reactiveEntityToDto %>;
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
const returnPrefix = returnDirectly ? 'return' : `${instanceType} ${instanceName} =`;
|
|
25
25
|
%>
|
|
26
26
|
<%_ if (!viaService) { _%>
|
|
27
|
-
<%- returnPrefix %> <%= entityInstance %>Repository.<% if (
|
|
27
|
+
<%- returnPrefix %> <%= entityInstance %>Repository.<% if (implementsEagerLoadApis) { %>findOneWithEagerRelationships(id)<% } else { %>findById(id)<% } %><% if (!dtoMapstruct) { %>;<% } else { %>
|
|
28
28
|
.map(<%= entityToDtoReference %>);<% } %>
|
|
29
29
|
<%_ } else { _%>
|
|
30
30
|
<%- returnPrefix %> <%= entityInstance %>Service.findOne(id);
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
See the License for the specific language governing permissions and
|
|
17
17
|
limitations under the License.
|
|
18
18
|
-%>
|
|
19
|
-
<%_
|
|
19
|
+
<%_
|
|
20
|
+
const beans = [];
|
|
20
21
|
if (viaService) {
|
|
21
22
|
beans.push({class: `${entityClass}Service`, instance: `${entityInstance}Service`});
|
|
22
23
|
beans.push({class: `${entityClass}Repository`, instance: `${entityInstance}Repository`});
|
|
@@ -49,8 +50,16 @@
|
|
|
49
50
|
}
|
|
50
51
|
_%>
|
|
51
52
|
|
|
52
|
-
|
|
53
|
+
<%_ for (const bean of beans) { _%>
|
|
54
|
+
private final <%= bean.class %> <%= bean.instance %>;
|
|
53
55
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
<%_ } _%>
|
|
57
|
+
public <%= constructorName %>(
|
|
58
|
+
<%_ for (const bean of beans) { _%>
|
|
59
|
+
<%= bean.class %> <%= bean.instance %><% if (bean !== beans[beans.length -1]) { %>,<% } %>
|
|
60
|
+
<%_ } _%>
|
|
61
|
+
) {
|
|
62
|
+
<%_ for (const bean of beans) { _%>
|
|
63
|
+
this.<%= bean.instance %> = <%= bean.instance %>;
|
|
64
|
+
<%_ } _%>
|
|
56
65
|
}
|
|
@@ -25,7 +25,7 @@ const returnPrefix = (isService) ? 'return' : returnType + '<' + instanceType +
|
|
|
25
25
|
const mapper = entityInstance + 'Mapper';
|
|
26
26
|
_%>
|
|
27
27
|
<%_ if (viaService) { _%>
|
|
28
|
-
<%_ if(reactive) { _%>
|
|
28
|
+
<%_ if (reactive) { _%>
|
|
29
29
|
Mono<<%= instanceType %>> result = <%= entityInstance %>Service.partialUpdate(<%= instanceName %>);
|
|
30
30
|
<%_ } else { _%>
|
|
31
31
|
Optional<<%= instanceType %>> result = <%= entityInstance %>Service.partialUpdate(<%= instanceName %>);
|
|
@@ -49,7 +49,7 @@ _%>
|
|
|
49
49
|
<% } %>
|
|
50
50
|
return existing<%= entityClass %>;
|
|
51
51
|
})
|
|
52
|
-
|
|
52
|
+
<% if (!updatableEntity) { %>// <%} %>.<%= mapOrFlatMap %>(<%= entityInstance %>Repository::save)
|
|
53
53
|
<%_ if (searchEngineElasticsearch) { _%>
|
|
54
54
|
.<%= mapOrFlatMap %>(saved<%= entityClass %> -> {
|
|
55
55
|
<%= entityInstance %>SearchRepository.save(saved<%= entityClass %>);
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
importSection: 0,
|
|
23
23
|
staticImportSection: 0,
|
|
24
24
|
annotationSection: 0,
|
|
25
|
+
additionalInterfacesSection: 0,
|
|
25
26
|
classStaticFieldsSection: 0,
|
|
26
27
|
classFieldsSection: 0,
|
|
27
28
|
classAdditionalFieldsSection: 0,
|
|
@@ -92,7 +93,7 @@ import <%= otherEntity.entityAbsoluteClass %>;
|
|
|
92
93
|
<%_ } _%>
|
|
93
94
|
<%_ } _%>
|
|
94
95
|
<&- fragments.annotationSection() -&>
|
|
95
|
-
public class <%= persistClass %> implements Serializable {
|
|
96
|
+
public class <%= persistClass %> implements Serializable<&- fragments.additionalInterfacesSection() -&> {
|
|
96
97
|
|
|
97
98
|
private static final long serialVersionUID = 1L;
|
|
98
99
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<%#
|
|
2
|
+
Copyright 2013-2022 the original author or authors from the JHipster project.
|
|
3
|
+
|
|
4
|
+
This file is part of the JHipster project, see https://www.jhipster.tech/
|
|
5
|
+
for more information.
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
|
18
|
+
-%>
|
|
19
|
+
<%#
|
|
20
|
+
This is a fragment file, it will be merged into to root template if available.
|
|
21
|
+
EJS fragments will process % delimiter tags in template and & delimiter tags in the merge process.
|
|
22
|
+
-%>
|
|
23
|
+
<&_ if (fragment.classAdditionalFieldsMethodsSection) { -&>
|
|
24
|
+
|
|
25
|
+
@PostLoad
|
|
26
|
+
@PostPersist
|
|
27
|
+
public void updateEntityState() {
|
|
28
|
+
this.setIsPersisted();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
<&_ } -&>
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<%#
|
|
2
|
+
Copyright 2013-2022 the original author or authors from the JHipster project.
|
|
3
|
+
|
|
4
|
+
This file is part of the JHipster project, see https://www.jhipster.tech/
|
|
5
|
+
for more information.
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
|
18
|
+
-%>
|
|
19
|
+
<%#
|
|
20
|
+
This is a fragment file, it will be merged into to root template if available.
|
|
21
|
+
EJS fragments will process % delimiter tags in template and & delimiter tags in the merge process.
|
|
22
|
+
-%>
|
|
23
|
+
<&_ if (fragment.importSection) { -&>
|
|
24
|
+
import org.springframework.data.domain.Persistable;
|
|
25
|
+
<&_ } -&>
|
|
26
|
+
|
|
27
|
+
<&_ if (fragment.additionalInterfacesSection) { -&>
|
|
28
|
+
, Persistable<<%= primaryKey.type %>>
|
|
29
|
+
<&_ } -&>
|
|
30
|
+
|
|
31
|
+
<&_ if (fragment.classAdditionalFieldsSection) { -&>
|
|
32
|
+
@Transient
|
|
33
|
+
private boolean isPersisted;
|
|
34
|
+
<&_ } -&>
|
|
35
|
+
|
|
36
|
+
<&_ if (fragment.classAdditionalFieldsMethodsSection) { -&>
|
|
37
|
+
<%_ if (primaryKey.name !== 'id') { -%>
|
|
38
|
+
@Override
|
|
39
|
+
public <%= primaryKey.type %> getId() {
|
|
40
|
+
return this.<%= primaryKey.name %>;
|
|
41
|
+
}
|
|
42
|
+
<%_ } -%>
|
|
43
|
+
|
|
44
|
+
@Transient
|
|
45
|
+
@Override
|
|
46
|
+
public boolean isNew() {
|
|
47
|
+
return !this.isPersisted;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public <%= persistClass %> setIsPersisted() {
|
|
51
|
+
this.isPersisted = true;
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
<&_ } -&>
|
|
@@ -92,7 +92,7 @@ import org.springframework.data.relational.core.mapping.Table;
|
|
|
92
92
|
<&_ if (fragment.classAdditionalRelationshipsSection) { -&>
|
|
93
93
|
<%_ for (const relationship of relationships) { _%>
|
|
94
94
|
<%_ if (relationship.ownerSide && !relationship.collection && !relationship.id) { _%>
|
|
95
|
-
@Column("<%= relationship.
|
|
95
|
+
@Column("<%= relationship.joinColumnNames[0] %>")
|
|
96
96
|
private <%= relationship.otherEntity.primaryKey.type %> <%= relationship.relationshipFieldName %>Id;
|
|
97
97
|
<%_ } _%>
|
|
98
98
|
<%_ } _%>
|
package/generators/entity-server/templates/src/main/java/package/domain/EntityCallback.java.ejs
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<%#
|
|
2
|
+
Copyright 2013-2022 the original author or authors from the JHipster project.
|
|
3
|
+
|
|
4
|
+
This file is part of the JHipster project, see https://www.jhipster.tech/
|
|
5
|
+
for more information.
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
|
18
|
+
-%>
|
|
19
|
+
package <%= entityAbsolutePackage %>.domain;
|
|
20
|
+
|
|
21
|
+
import org.reactivestreams.Publisher;
|
|
22
|
+
import org.springframework.data.r2dbc.mapping.OutboundRow;
|
|
23
|
+
import org.springframework.data.r2dbc.mapping.event.AfterConvertCallback;
|
|
24
|
+
import org.springframework.data.r2dbc.mapping.event.AfterSaveCallback;
|
|
25
|
+
import org.springframework.data.relational.core.sql.SqlIdentifier;
|
|
26
|
+
import org.springframework.stereotype.Component;
|
|
27
|
+
|
|
28
|
+
import reactor.core.publisher.Mono;
|
|
29
|
+
|
|
30
|
+
@Component
|
|
31
|
+
public class <%= persistClass %>Callback implements AfterSaveCallback<<%= persistClass %>>, AfterConvertCallback<<%= persistClass %>> {
|
|
32
|
+
|
|
33
|
+
@Override
|
|
34
|
+
public Publisher<<%= persistClass %>> onAfterConvert(<%= persistClass %> entity, SqlIdentifier table) {
|
|
35
|
+
return Mono.just(entity.setIsPersisted());
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@Override
|
|
39
|
+
public Publisher<<%= persistClass %>> onAfterSave(<%= persistClass %> entity, OutboundRow outboundRow,
|
|
40
|
+
SqlIdentifier table) {
|
|
41
|
+
return Mono.just(entity.setIsPersisted());
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -20,13 +20,13 @@ package <%= entityAbsolutePackage %>.repository;
|
|
|
20
20
|
|
|
21
21
|
import <%= entityAbsolutePackage %>.domain.<%= persistClass %>;
|
|
22
22
|
|
|
23
|
-
<%_ if (
|
|
23
|
+
<%_ if (implementsEagerLoadApis) { _%>
|
|
24
24
|
import org.springframework.data.domain.Page;
|
|
25
25
|
import org.springframework.data.domain.Pageable;
|
|
26
26
|
<%_ } _%>
|
|
27
27
|
<%_ if (databaseTypeSql) { _%>
|
|
28
28
|
import org.springframework.data.jpa.repository.*;
|
|
29
|
-
<%_ if (
|
|
29
|
+
<%_ if (implementsEagerLoadApis) { _%>
|
|
30
30
|
import org.springframework.data.repository.query.Param;
|
|
31
31
|
<%_ } _%>
|
|
32
32
|
<%_ } _%>
|
|
@@ -42,10 +42,10 @@ import org.springframework.data.cassandra.repository.CassandraRepository;
|
|
|
42
42
|
<%_ } _%>
|
|
43
43
|
import org.springframework.stereotype.Repository;
|
|
44
44
|
<%_ if (databaseTypeSql || databaseTypeMongodb) { _%>
|
|
45
|
-
<%_ if (
|
|
45
|
+
<%_ if (implementsEagerLoadApis || relationships.some(r => r.relationshipManyToOne && r.otherEntityUser)) { _%>
|
|
46
46
|
import java.util.List;
|
|
47
47
|
<%_ } _%>
|
|
48
|
-
<%_ if (
|
|
48
|
+
<%_ if (implementsEagerLoadApis) { _%>
|
|
49
49
|
import java.util.Optional;
|
|
50
50
|
<%_ } _%>
|
|
51
51
|
<%_ } _%>
|
|
@@ -57,7 +57,7 @@ import java.util.UUID;
|
|
|
57
57
|
/**
|
|
58
58
|
* Spring Data <%= officialDatabaseType %> repository for the <%= persistClass %> entity.
|
|
59
59
|
*/
|
|
60
|
-
<%_ if (!
|
|
60
|
+
<%_ if (!implementsEagerLoadApis) { _%>
|
|
61
61
|
@SuppressWarnings("unused")
|
|
62
62
|
<%_ } _%>
|
|
63
63
|
@Repository
|
|
@@ -69,7 +69,7 @@ public interface <%= entityClass %>Repository extends <% if (containsBagRelation
|
|
|
69
69
|
List<<%= persistClass %>> findBy<%= relationship.relationshipNameCapitalized %>IsCurrentUser();
|
|
70
70
|
<%_ } _%>
|
|
71
71
|
<%_ } _%>
|
|
72
|
-
<%_ if (
|
|
72
|
+
<%_ if (implementsEagerLoadApis) { _%>
|
|
73
73
|
<%_ if (databaseTypeSql) { _%>
|
|
74
74
|
|
|
75
75
|
<%_ const containsToOneEagerRelationship = relationships.some(relationship => relationship.relationshipEagerLoad && !relationship.bagRelationship); _%>
|
|
@@ -38,13 +38,12 @@ import java.util.Map;
|
|
|
38
38
|
import java.util.Map.Entry;
|
|
39
39
|
import java.util.Optional;
|
|
40
40
|
import org.springframework.data.domain.Pageable;
|
|
41
|
-
<%_ if (databaseTypeSql) { _%>
|
|
42
41
|
import io.r2dbc.spi.Row;
|
|
43
42
|
import io.r2dbc.spi.RowMetadata;
|
|
44
43
|
import static org.springframework.data.relational.core.query.Criteria.where;
|
|
45
|
-
|
|
44
|
+
<%_ if (containsBagRelationships) { _%>
|
|
46
45
|
import static org.springframework.data.relational.core.query.Query.query;
|
|
47
|
-
|
|
46
|
+
<%_ } _%>
|
|
48
47
|
import org.springframework.data.r2dbc.convert.R2dbcConverter;
|
|
49
48
|
import org.springframework.data.r2dbc.core.R2dbcEntityOperations;
|
|
50
49
|
import org.springframework.data.r2dbc.core.R2dbcEntityTemplate;
|
|
@@ -58,7 +57,6 @@ import org.springframework.data.relational.core.sql.Table;
|
|
|
58
57
|
import org.springframework.data.relational.repository.support.MappingRelationalEntityInformation;
|
|
59
58
|
import org.springframework.r2dbc.core.DatabaseClient;
|
|
60
59
|
import org.springframework.r2dbc.core.RowsFetchSpec;
|
|
61
|
-
<%_ } _%>
|
|
62
60
|
|
|
63
61
|
import <%= entityAbsolutePackage %>.domain.<%= persistClass %>;
|
|
64
62
|
<% relationships.forEach(function(rel) {
|
|
@@ -105,7 +103,7 @@ class <%= entityClass %>RepositoryInternalImpl extends SimpleR2dbcRepository<<%=
|
|
|
105
103
|
<%_ relationships.forEach(function(rel) {
|
|
106
104
|
if (rel.shouldWriteJoinTable) {
|
|
107
105
|
_%>
|
|
108
|
-
private final static EntityManager.LinkTable <%= rel.relationshipName %>Link = new EntityManager.LinkTable("<%= rel.joinTable.name %>", "<%= getColumnName(name) %>
|
|
106
|
+
private final static EntityManager.LinkTable <%= rel.relationshipName %>Link = new EntityManager.LinkTable("<%= rel.joinTable.name %>", "<%= entity.entityTableName %>_<%= getColumnName(entity.primaryKey.name) %>", "<%= rel.joinColumnNames[0] %>");
|
|
109
107
|
<%_ }
|
|
110
108
|
}); _%>
|
|
111
109
|
|
|
@@ -137,9 +135,8 @@ _%>
|
|
|
137
135
|
columns.addAll(<%= rel.otherEntityNameCapitalized %>SqlHelper.getColumns(<%= rel.relationshipName %>Table, "<%= rel.relationshipName %>"));
|
|
138
136
|
<%_ }); _%>
|
|
139
137
|
SelectFromAndJoin<% if (reactiveEagerRelations.length > 0) { %>Condition<% } %> selectFrom = Select.builder().select(columns).from(entityTable)
|
|
140
|
-
<%_ reactiveEagerRelations.forEach(function(rel) {
|
|
141
|
-
|
|
142
|
-
.leftOuterJoin(<%= rel.relationshipName %>Table).on(Column.create("<%= colName %>", entityTable)).equals(Column.create("id", <%= rel.relationshipName %>Table ))
|
|
138
|
+
<%_ reactiveEagerRelations.forEach(function(rel) { _%>
|
|
139
|
+
.leftOuterJoin(<%= rel.relationshipName %>Table).on(Column.create("<%= rel.joinColumnNames[0] %>", entityTable)).equals(Column.create("<%= rel.otherEntity.primaryKey.fields[0].columnName %>", <%= rel.relationshipName %>Table ))
|
|
143
140
|
<%_ }); _%>;
|
|
144
141
|
|
|
145
142
|
String select = entityManager.createSelect(selectFrom, <%= persistClass %>.class, pageable, criteria);
|
|
@@ -153,10 +150,10 @@ _%>
|
|
|
153
150
|
|
|
154
151
|
@Override
|
|
155
152
|
public Mono<<%= persistClass %>> findById(<%= primaryKey.type %> id) {
|
|
156
|
-
return createQuery(null, where(EntityManager.ENTITY_ALIAS + ".<%= primaryKey.
|
|
153
|
+
return createQuery(null, where(EntityManager.ENTITY_ALIAS + ".<%= primaryKey.fields[0].columnName %>").is(id)).one();
|
|
157
154
|
}
|
|
158
155
|
|
|
159
|
-
<%_ if (
|
|
156
|
+
<%_ if (implementsEagerLoadApis) { _%>
|
|
160
157
|
|
|
161
158
|
@Override
|
|
162
159
|
public Mono<<%= persistClass %>> findOneWithEagerRelationships(<%= primaryKey.type %> id) {
|
|
@@ -190,30 +187,30 @@ _%>
|
|
|
190
187
|
return entityManager.insert(entity);
|
|
191
188
|
}
|
|
192
189
|
<%_ } _%>
|
|
193
|
-
return super.save(entity)<% if (
|
|
190
|
+
return super.save(entity)<% if (containsBagRelationships) { %>.flatMap((S e) -> updateRelations(e))<% } %>;
|
|
194
191
|
}
|
|
195
192
|
|
|
196
|
-
<%_ if (
|
|
193
|
+
<%_ if (containsBagRelationships) { _%>
|
|
197
194
|
protected <S extends <%= persistClass %>> Mono<S> updateRelations(S entity) {
|
|
198
195
|
<%_ relationships.filter(function(rel) {
|
|
199
196
|
return (rel.relationshipManyToMany && rel.ownerSide);
|
|
200
197
|
}).forEach(function(rel, idx) { _%>
|
|
201
198
|
<%_ if (idx === 0) { _%>
|
|
202
|
-
Mono<Void> result = entityManager.updateLinkTable(<%= rel.relationshipName %>Link, entity.get<%= primaryKey.nameCapitalized %>(), entity.get<%= rel.relationshipNameCapitalizedPlural %>().stream().map(<%= asEntity(rel.otherEntityNameCapitalized) %>::
|
|
199
|
+
Mono<Void> result = entityManager.updateLinkTable(<%= rel.relationshipName %>Link, entity.get<%= primaryKey.nameCapitalized %>(), entity.get<%= rel.relationshipNameCapitalizedPlural %>().stream().map(<%= asEntity(rel.otherEntityNameCapitalized) %>::get<%= rel.otherEntity.primaryKey.nameCapitalized %>)).then();
|
|
203
200
|
<%_ } else { _%>
|
|
204
|
-
result = result.and(entityManager.updateLinkTable(<%= rel.relationshipName %>Link, entity.get<%= primaryKey.nameCapitalized %>(), entity.get<%= rel.relationshipNameCapitalizedPlural %>().stream().map(<%= asEntity(rel.otherEntityNameCapitalized) %>::
|
|
201
|
+
result = result.and(entityManager.updateLinkTable(<%= rel.relationshipName %>Link, entity.get<%= primaryKey.nameCapitalized %>(), entity.get<%= rel.relationshipNameCapitalizedPlural %>().stream().map(<%= asEntity(rel.otherEntityNameCapitalized) %>::get<%= rel.otherEntity.primaryKey.nameCapitalized %>)));
|
|
205
202
|
<%_ } _%>
|
|
206
203
|
<%_ }); _%>
|
|
207
204
|
return result.thenReturn(entity);
|
|
208
205
|
}
|
|
209
206
|
|
|
210
207
|
@Override
|
|
211
|
-
public Mono<Void> deleteById(
|
|
208
|
+
public Mono<Void> deleteById(<%= primaryKey.type %> entityId) {
|
|
212
209
|
return deleteRelations(entityId)
|
|
213
210
|
.then(super.deleteById(entityId));
|
|
214
211
|
}
|
|
215
212
|
|
|
216
|
-
protected Mono<Void> deleteRelations(
|
|
213
|
+
protected Mono<Void> deleteRelations(<%= primaryKey.type %> entityId) {
|
|
217
214
|
<%_ relationships.filter(function(rel) {
|
|
218
215
|
return (rel.relationshipManyToMany && rel.ownerSide);
|
|
219
216
|
}).forEach(function(rel, idx) { _%>
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
-%>
|
|
19
19
|
package <%= packageName %>.repository;
|
|
20
20
|
|
|
21
|
+
import java.util.Collections;
|
|
21
22
|
import java.util.List;
|
|
22
23
|
import java.util.Optional;
|
|
23
24
|
<%_ if (fieldsContainUUID) { _%>
|
|
@@ -25,9 +26,9 @@ import java.util.UUID;
|
|
|
25
26
|
<%_ } _%>
|
|
26
27
|
|
|
27
28
|
import javax.persistence.EntityManager;
|
|
29
|
+
import javax.persistence.PersistenceContext;
|
|
28
30
|
|
|
29
31
|
import org.hibernate.annotations.QueryHints;
|
|
30
|
-
import org.springframework.beans.factory.annotation.Autowired;
|
|
31
32
|
import org.springframework.data.domain.Page;
|
|
32
33
|
import org.springframework.data.domain.PageImpl;
|
|
33
34
|
|
|
@@ -37,7 +38,7 @@ import <%= packageName %>.domain.<%= persistClass %>;
|
|
|
37
38
|
* Utility repository to load bag relationships based on https://vladmihalcea.com/hibernate-multiplebagfetchexception/
|
|
38
39
|
*/
|
|
39
40
|
public class <%= entityClass %>RepositoryWithBagRelationshipsImpl implements <%= entityClass %>RepositoryWithBagRelationships {
|
|
40
|
-
@
|
|
41
|
+
@PersistenceContext
|
|
41
42
|
private EntityManager entityManager;
|
|
42
43
|
|
|
43
44
|
@Override
|
|
@@ -61,7 +62,7 @@ public class <%= entityClass %>RepositoryWithBagRelationshipsImpl implements <%=
|
|
|
61
62
|
<%_ for (const relationship of relationships.filter(relationship => relationship.bagRelationship)) { _%>
|
|
62
63
|
.map(this::fetch<%= relationship.relationshipNameCapitalizedPlural %>)
|
|
63
64
|
<%_ } _%>
|
|
64
|
-
.
|
|
65
|
+
.orElse(Collections.emptyList());
|
|
65
66
|
}
|
|
66
67
|
<%_ for (const relationship of relationships.filter(relationship => relationship.bagRelationship)) { _%>
|
|
67
68
|
|
|
@@ -22,15 +22,11 @@ import <%= entityAbsolutePackage %>.domain.<%= persistClass %>;
|
|
|
22
22
|
<%_ if (databaseTypeCassandra) { _%>
|
|
23
23
|
import org.springframework.data.cassandra.repository.ReactiveCassandraRepository;
|
|
24
24
|
<%_ } _%>
|
|
25
|
-
<%_ if (databaseTypeCouchbase) { _%>
|
|
26
|
-
import org.springframework.data.couchbase.core.query.Query;
|
|
27
|
-
import org.springframework.data.couchbase.repository.ReactiveCouchbaseSortingRepository;
|
|
28
|
-
<%_ } _%>
|
|
29
25
|
<%_ if (databaseTypeNeo4j) { _%>
|
|
30
26
|
import org.springframework.data.neo4j.repository.ReactiveNeo4jRepository;
|
|
31
27
|
import org.springframework.data.neo4j.repository.query.Query;
|
|
32
28
|
<%_ } _%>
|
|
33
|
-
<%_ if (!paginationNo ||
|
|
29
|
+
<%_ if (!paginationNo || implementsEagerLoadApis || databaseTypeSql) { _%>
|
|
34
30
|
import org.springframework.data.domain.Pageable;
|
|
35
31
|
<%_ } _%>
|
|
36
32
|
<%_ if (databaseTypeSql) { _%>
|
|
@@ -39,16 +35,16 @@ import org.springframework.data.repository.reactive.ReactiveCrudRepository;
|
|
|
39
35
|
import org.springframework.data.relational.core.query.Criteria;
|
|
40
36
|
<%_ } _%>
|
|
41
37
|
<%_ if (databaseTypeMongodb) { _%>
|
|
42
|
-
<%_ if (
|
|
38
|
+
<%_ if (implementsEagerLoadApis) { _%>
|
|
43
39
|
import org.springframework.data.mongodb.repository.Query;
|
|
44
40
|
<%_ } _%>
|
|
45
41
|
import org.springframework.data.mongodb.repository.ReactiveMongoRepository;
|
|
46
42
|
<%_ } _%>
|
|
47
43
|
import org.springframework.stereotype.Repository;
|
|
48
|
-
<%_ if (
|
|
44
|
+
<%_ if (databaseTypeSql || !paginationNo || implementsEagerLoadApis) { _%>
|
|
49
45
|
import reactor.core.publisher.Flux;
|
|
50
46
|
<%_ } _%>
|
|
51
|
-
<%_ if (
|
|
47
|
+
<%_ if (implementsEagerLoadApis || databaseTypeSql) { _%>
|
|
52
48
|
import reactor.core.publisher.Mono;
|
|
53
49
|
<%_ } _%>
|
|
54
50
|
<%_ if (primaryKey.typeUUID) { _%>
|
|
@@ -61,13 +57,13 @@ import java.util.UUID;
|
|
|
61
57
|
*/
|
|
62
58
|
@SuppressWarnings("unused")
|
|
63
59
|
@Repository
|
|
64
|
-
public interface <%= entityClass %>Repository extends <% if (databaseTypeSql) { %>ReactiveCrud<% } if (databaseTypeMongodb) { %>ReactiveMongo<% } if (
|
|
60
|
+
public interface <%= entityClass %>Repository extends <% if (databaseTypeSql) { %>ReactiveCrud<% } if (databaseTypeMongodb) { %>ReactiveMongo<% } if (databaseTypeNeo4j) { %>ReactiveNeo4j<% } if (databaseTypeCassandra) { %>ReactiveCassandra<% } %>Repository<<%= persistClass %>, <%= primaryKey.type %>><% if (databaseTypeSql) { %>, <%= entityClass %>RepositoryInternal<% } %> {
|
|
65
61
|
|
|
66
62
|
<%_ if (!paginationNo) { _%>
|
|
67
63
|
Flux<<%= persistClass %>> findAllBy(Pageable pageable);
|
|
68
64
|
<%_ } _%>
|
|
69
|
-
<%_ if (
|
|
70
|
-
<%_ if (
|
|
65
|
+
<%_ if (implementsEagerLoadApis) { _%>
|
|
66
|
+
<%_ if (databaseTypeMongodb) { _%>
|
|
71
67
|
|
|
72
68
|
@Query("<%= (databaseTypeMongodb) ? '{}' : '#{#n1ql.selectEntity} WHERE #{#n1ql.filter}' %>")
|
|
73
69
|
Flux<<%= persistClass %>> findAllWithEagerRelationships(Pageable pageable);
|
|
@@ -90,7 +86,7 @@ public interface <%= entityClass %>Repository extends <% if (databaseTypeSql) {
|
|
|
90
86
|
<%_ } _%>
|
|
91
87
|
<%_ } _%>
|
|
92
88
|
<%_ if (databaseTypeSql) { _%>
|
|
93
|
-
<%_ if (
|
|
89
|
+
<%_ if (implementsEagerLoadApis) { _%>
|
|
94
90
|
|
|
95
91
|
@Override
|
|
96
92
|
Mono<<%= persistClass %>> findOneWithEagerRelationships(<%= primaryKey.type %> id);
|
|
@@ -108,21 +104,21 @@ public interface <%= entityClass %>Repository extends <% if (databaseTypeSql) {
|
|
|
108
104
|
let ownerSide = relationship.ownerSide; _%>
|
|
109
105
|
<%_ if (relationship.relationshipManyToOne || (relationship.relationshipOneToOne && ownerSide)) { _%>
|
|
110
106
|
|
|
111
|
-
@Query("SELECT * FROM <%= entityTableName %> entity WHERE entity.<%=
|
|
107
|
+
@Query("SELECT * FROM <%= entityTableName %> entity WHERE entity.<%= relationship.joinColumnNames[0] %> = :id")
|
|
112
108
|
Flux<<%= persistClass %>> findBy<%= relationship.relationshipNameCapitalized %>(<%= primaryKey.type %> id);
|
|
113
109
|
|
|
114
|
-
@Query("SELECT * FROM <%= entityTableName %> entity WHERE entity.<%=
|
|
110
|
+
@Query("SELECT * FROM <%= entityTableName %> entity WHERE entity.<%= relationship.joinColumnNames[0] %> IS NULL")
|
|
115
111
|
Flux<<%= persistClass %>> findAllWhere<%= relationship.relationshipNameCapitalized %>IsNull();
|
|
116
112
|
<%_ } else if (relationship.shouldWriteJoinTable) { _%>
|
|
117
113
|
|
|
118
|
-
@Query("SELECT entity.* FROM <%= entityTableName %> entity JOIN <%= relationship.joinTable.name %> joinTable ON entity.
|
|
114
|
+
@Query("SELECT entity.* FROM <%= entityTableName %> entity JOIN <%= relationship.joinTable.name %> joinTable ON entity.<%= primaryKey.fields[0].columnName %> = joinTable.<%= relationship.joinColumnNames[0] %> WHERE joinTable.<%= relationship.joinColumnNames[0] %> = :id")
|
|
119
115
|
Flux<<%= persistClass %>> findBy<%= relationship.relationshipNameCapitalized %>(<%= primaryKey.type %> id);
|
|
120
116
|
<%_ } else if (relationship.relationshipOneToOne && !ownerSide) {
|
|
121
117
|
let otherEntityRelationshipName = relationship.otherEntityRelationshipName;
|
|
122
118
|
let otherEntityTableName = relationship.otherEntityTableName;
|
|
123
119
|
_%>
|
|
124
120
|
|
|
125
|
-
@Query("SELECT * FROM <%= entityTableName %> entity WHERE entity.
|
|
121
|
+
@Query("SELECT * FROM <%= entityTableName %> entity WHERE entity.<%= primaryKey.fields[0].columnName %> not in (select <%= relationship.joinColumnNames[0]%> from <%= otherEntityTableName %>)")
|
|
126
122
|
Flux<<%= persistClass %>> findAllWhere<%= relationship.relationshipNameCapitalized %>IsNull();
|
|
127
123
|
<%_ } _%>
|
|
128
124
|
<%_ } _%>
|
|
@@ -138,10 +134,8 @@ public interface <%= entityClass %>Repository extends <% if (databaseTypeSql) {
|
|
|
138
134
|
|
|
139
135
|
@Override
|
|
140
136
|
Mono<Void> deleteById(<%= primaryKey.type %> id);
|
|
141
|
-
<%_ } _%>
|
|
142
|
-
|
|
143
137
|
}
|
|
144
|
-
|
|
138
|
+
|
|
145
139
|
interface <%= entityClass %>RepositoryInternal {
|
|
146
140
|
<S extends <%= persistClass %>> Mono<S> save(S entity);
|
|
147
141
|
|
|
@@ -153,7 +147,7 @@ interface <%= entityClass %>RepositoryInternal {
|
|
|
153
147
|
|
|
154
148
|
Flux<<%= persistClass %>> findAllBy(Pageable pageable, Criteria criteria);
|
|
155
149
|
|
|
156
|
-
<%_ if (
|
|
150
|
+
<%_ if (implementsEagerLoadApis) { _%>
|
|
157
151
|
|
|
158
152
|
Mono<<%= persistClass %>> findOneWithEagerRelationships(<%= primaryKey.type %> id);
|
|
159
153
|
|
|
@@ -162,8 +156,6 @@ interface <%= entityClass %>RepositoryInternal {
|
|
|
162
156
|
Flux<<%= persistClass %>> findAllWithEagerRelationships(Pageable page);
|
|
163
157
|
|
|
164
158
|
Mono<Void> deleteById(<%= primaryKey.type %> id);
|
|
165
|
-
|
|
166
159
|
<%_ } _%>
|
|
167
|
-
|
|
168
|
-
}
|
|
169
160
|
<%_ } _%>
|
|
161
|
+
}
|
|
@@ -29,7 +29,7 @@ public class <%= entityClass %>SqlHelper {
|
|
|
29
29
|
|
|
30
30
|
public static List<Expression> getColumns(Table table, String columnPrefix) {
|
|
31
31
|
List<Expression> columns = new ArrayList<>();
|
|
32
|
-
<%_ fields.forEach(function(field) {
|
|
32
|
+
<%_ fields.filter(field => !field.transient).forEach(function(field) {
|
|
33
33
|
let col = field.fieldNameAsDatabaseColumn;
|
|
34
34
|
_%>
|
|
35
35
|
columns.add(Column.aliased("<%= col %>", table, columnPrefix + "_<%= col %>"));
|
|
@@ -39,7 +39,7 @@ public class <%= entityClass %>SqlHelper {
|
|
|
39
39
|
<%_ }); _%>
|
|
40
40
|
|
|
41
41
|
<%_ reactiveRegularEagerRelations.forEach(function(rel) { _%>
|
|
42
|
-
columns.add(Column.aliased("<%=
|
|
42
|
+
columns.add(Column.aliased("<%= rel.joinColumnNames[0] %>", table, columnPrefix + "_<%= rel.joinColumnNames[0] %>"));
|
|
43
43
|
<%_ }); _%>
|
|
44
44
|
return columns;
|
|
45
45
|
}
|
|
@@ -62,7 +62,7 @@ public class <%= entityClass %>RowMapper implements BiFunction<Row, String, <%=
|
|
|
62
62
|
@Override
|
|
63
63
|
public <%= persistClass %> apply(Row row, String prefix) {
|
|
64
64
|
<%= persistClass %> entity = new <%= persistClass %>();
|
|
65
|
-
<%_ fields.forEach(function(field) {
|
|
65
|
+
<%_ fields.filter(field => !field.transient).forEach(function(field) {
|
|
66
66
|
let fieldType = field.fieldType;
|
|
67
67
|
if (field.blobContentTypeText) {
|
|
68
68
|
fieldType = 'String';
|
|
@@ -73,7 +73,7 @@ public class <%= entityClass %>RowMapper implements BiFunction<Row, String, <%=
|
|
|
73
73
|
entity.set<%= field.fieldInJavaBeanMethod %>(converter.fromRow(row, prefix + "_<%= field.fieldNameAsDatabaseColumn %>", <%= fieldType %>.class));
|
|
74
74
|
<%_ }); _%>
|
|
75
75
|
<%_ reactiveRegularEagerRelations.forEach(function(rel) { _%>
|
|
76
|
-
entity.set<%= rel.relationshipNameCapitalized %>Id(converter.fromRow(row, prefix + "_<%=
|
|
76
|
+
entity.set<%= rel.relationshipNameCapitalized %>Id(converter.fromRow(row, prefix + "_<%= rel.joinColumnNames[0] %>", <%= rel.otherEntity.primaryKey.type %>.class));
|
|
77
77
|
<%_ }); _%>
|
|
78
78
|
return entity;
|
|
79
79
|
}
|