diff --git a/generators/entity-server/templates/partials/it_patch_update.partial.java.ejs b/generators/entity-server/templates/partials/it_patch_update.partial.java.ejs index d024189e8a1..ad0be707fba 100644 --- a/generators/entity-server/templates/partials/it_patch_update.partial.java.ejs +++ b/generators/entity-server/templates/partials/it_patch_update.partial.java.ejs @@ -18,26 +18,26 @@ -%> // Initialize the database <%_ if (primaryKey.type === 'UUID' && databaseType !== 'sql') { _%> - <%= asEntity(entityInstance) %>.set<%= primaryKey.nameCapitalized %>(UUID.randomUUID()); + <%= persistInstance %>.set<%= primaryKey.nameCapitalized %>(UUID.randomUUID()); <%_ } _%> -<%= entityInstance %>Repository.<%= saveMethod %>(<%= asEntity(entityInstance) %>)<%= callBlock %>; +<%= entityInstance %>Repository.<%= saveMethod %>(<%= persistInstance %>)<%= callBlock %>; int databaseSizeBeforeUpdate = <%= entityInstance %>Repository.findAll()<%= callListBlock %>.size(); // Update the <%= entityInstance %> using partial update -<%= asEntity(entityClass) %> partialUpdated<%= asEntity(entityClass) %> = new <%= asEntity(entityClass) %>(); -partialUpdated<%= asEntity(entityClass) %>.set<%= primaryKey.nameCapitalized %>(<%= asEntity(entityInstance) %>.get<%= primaryKey.nameCapitalized %>()); +<%= persistClass %> partialUpdated<%= persistClass %> = new <%= persistClass %>(); +partialUpdated<%= persistClass %>.set<%= primaryKey.nameCapitalized %>(<%= persistInstance %>.get<%= primaryKey.nameCapitalized %>()); <%_ fieldsToUpdate = fields.filter(field => field.includeField) %> <%_ if (fluentMethods && fieldsToUpdate.length > 0) { _%> - partialUpdated<%= asEntity(entityClass) %><% for (field of fieldsToUpdate) { %> + partialUpdated<%= persistClass %><% for (field of fieldsToUpdate) { %> .<%= field.fieldName %>(<%= 'UPDATED_' + field.fieldNameUnderscored.toUpperCase() %>)<% if (field.fieldWithContentType) { %> .<%= field.fieldName %>ContentType(<%= 'UPDATED_' + field.fieldNameUnderscored.toUpperCase() %>_CONTENT_TYPE)<% } %><% } %>; <%_ } else { _%> <%_ for (field of fieldsToUpdate) { _%> <%_ if (field.includeField) { %> - partialUpdated<%= asEntity(entityClass) %>.set<%= field.fieldInJavaBeanMethod %>(<%= field.updateWithValue %>); + partialUpdated<%= persistClass %>.set<%= field.fieldInJavaBeanMethod %>(<%= field.updateWithValue %>); <%_ if (field.fieldWithContentType) { _%> - partialUpdated<%= asEntity(entityClass) %>.set<%= field.fieldInJavaBeanMethod %>ContentType(<%= field.updateWithValue %>_CONTENT_TYPE); + partialUpdated<%= persistClass %>.set<%= field.fieldInJavaBeanMethod %>ContentType(<%= field.updateWithValue %>_CONTENT_TYPE); <%_ } _%> <%_ } _%> <%_ } _%> @@ -46,14 +46,14 @@ partialUpdated<%= asEntity(entityClass) %>.set<%= primaryKey.nameCapitalized %>( <%_ if (!reactive) { _%> rest<%= entityClass %>MockMvc.perform(patch(ENTITY_API_URL)<% if (testsNeedCsrf) { %>.with(csrf())<% }%> .contentType("application/merge-patch+json") -.content(TestUtil.convertObjectToJsonBytes(<%= 'partialUpdated' + asEntity(entityClass) %>))) +.content(TestUtil.convertObjectToJsonBytes(<%= 'partialUpdated' + persistClass %>))) .andExpect(status().isOk()); <%_ } else { _%> webTestClient .patch() .uri(ENTITY_API_URL) .contentType(MediaType.valueOf("application/merge-patch+json")) -.bodyValue(TestUtil.convertObjectToJsonBytes(<%= 'partialUpdated' + asEntity(entityClass) %>)) +.bodyValue(TestUtil.convertObjectToJsonBytes(<%= 'partialUpdated' + persistClass %>)) .exchange() .expectStatus() .isOk(); @@ -63,9 +63,9 @@ webTestClient <%_ if (databaseType === 'couchbase') { _%> SecurityContextHolder.setContext(TestSecurityContextHolder.getContext()); <%_ } _%> -List<<%= asEntity(entityClass) %>> <%= entityInstance %>List = <%= entityInstance %>Repository.findAll()<%= callListBlock %>; +List<<%= persistClass %>> <%= entityInstance %>List = <%= entityInstance %>Repository.findAll()<%= callListBlock %>; assertThat(<%= entityInstance %>List).hasSize(databaseSizeBeforeUpdate); -<%= asEntity(entityClass) %> test<%= entityClass %> = <%= entityInstance %>List.get(<%= entityInstance %>List.size() - 1); +<%= persistClass %> test<%= entityClass %> = <%= entityInstance %>List.get(<%= entityInstance %>List.size() - 1); <%_ for (field of fields) { if (field.fieldType === 'ZonedDateTime') { _%> assertThat(test<%= entityClass %>.get<%= field.fieldInJavaBeanMethod %>()).isEqualTo(<%= field.testWithConstant %>); <%_ } else if ((field.fieldType === 'byte[]' || field.fieldType === 'ByteBuffer') && field.fieldTypeBlobContent !== 'text') { _%> diff --git a/generators/entity-server/templates/partials/save_template.ejs b/generators/entity-server/templates/partials/save_template.ejs index 38e8ac01045..a075a6fdb28 100644 --- a/generators/entity-server/templates/partials/save_template.ejs +++ b/generators/entity-server/templates/partials/save_template.ejs @@ -16,8 +16,8 @@ See the License for the specific language governing permissions and limitations under the License. -%> -<%_ const instanceType = (dto === 'mapstruct') ? asDto(entityClass) : asEntity(entityClass); -const instanceName = (dto === 'mapstruct') ? asDto(entityInstance) : asEntity(entityInstance); +<%_ const instanceType = restClass; +const instanceName = restInstance; const mapper = entityInstance + 'Mapper'; const dtoToEntity = mapper + '.' + 'toEntity'; const entityToDto = mapper + '.' + 'toDto'; @@ -40,20 +40,20 @@ if (isUsingMapsId === true) { <%_ } if (!viaService) { if (dto === 'mapstruct') { - resultEntity = asEntity(entityInstance); _%> - <%= asEntity(entityClass) %> <%= asEntity(entityInstance) %> = <%= dtoToEntity %>(<%= instanceName %>); + resultEntity = persistInstance; _%> + <%= persistClass %> <%= persistInstance %> = <%= dtoToEntity %>(<%= instanceName %>); <%_ if (isUsingMapsId === true) { _%> <%= mapsIdAssoc.otherEntity.primaryKey.type %> <%= otherEntityName %>Id = <%= instanceName %>.get<%= mapsIdAssoc.relationshipNameCapitalized %>().get<%= primaryKey.nameCapitalized %>(); - <%= mapsIdRepoInstance %>.findById(<%= otherEntityName %>Id).ifPresent(<%= asEntity(entityInstance) %>::<%_ if (fluentMethods === false) { _%>set<%= mapsIdAssoc.relationshipNameCapitalized %> <%_ } else { _%><%= mapsIdAssoc.relationshipName %><%_ } _%>); + <%= mapsIdRepoInstance %>.findById(<%= otherEntityName %>Id).ifPresent(<%= persistInstance %>::<%_ if (fluentMethods === false) { _%>set<%= mapsIdAssoc.relationshipNameCapitalized %> <%_ } else { _%><%= mapsIdAssoc.relationshipName %><%_ } _%>); <%_ } _%> - <%= asEntity(entityInstance) %> = <%= entityInstance %>Repository.save(<%= asEntity(entityInstance) %>); - <%= returnPrefix %> <%= entityToDto %>(<%= asEntity(entityInstance) %>); + <%= persistInstance %> = <%= entityInstance %>Repository.save(<%= persistInstance %>); + <%= returnPrefix %> <%= entityToDto %>(<%= persistInstance %>); <%_ } else { resultEntity = 'result'; _%> <%_ if (isUsingMapsId === true) { _%> <%= mapsIdAssoc.otherEntity.primaryKey.type %> <%= otherEntityName %>Id = <%= instanceName %>.get<%= mapsIdAssoc.relationshipNameCapitalized %>().get<%= primaryKey.nameCapitalized %>(); <%= mapsIdRepoInstance %>.findById(<%= otherEntityName %>Id).ifPresent(<%= instanceName %>::<%_ if (fluentMethods === false) { _%>set<%= mapsIdAssoc.relationshipNameCapitalized %> <%_ } else { _%><%= otherEntityName %><%_ } _%>); <%_ } _%> - <%= returnPrefix %> <%= entityInstance %>Repository.save(<%= asEntity(entityInstance) %>); + <%= returnPrefix %> <%= entityInstance %>Repository.save(<%= persistInstance %>); <%_ } if (searchEngine === 'elasticsearch') { _%> <%= entityInstance %>SearchRepository.save(<%= resultEntity %>); diff --git a/generators/entity-server/templates/reactive/partials/save_template.ejs b/generators/entity-server/templates/reactive/partials/save_template.ejs index cd403324085..7c032d9a110 100644 --- a/generators/entity-server/templates/reactive/partials/save_template.ejs +++ b/generators/entity-server/templates/reactive/partials/save_template.ejs @@ -16,8 +16,8 @@ See the License for the specific language governing permissions and limitations under the License. -%> -<%_ const instanceType = (dto === 'mapstruct') ? asDto(entityClass) : asEntity(entityClass); -const instanceName = (dto === 'mapstruct') ? asDto(entityInstance) : asEntity(entityInstance); +<%_ const instanceType = restClass; +const instanceName = restInstance; const mapper = entityInstance + 'Mapper'; const dtoToEntity = mapper + '.' + 'toEntity'; const entityToDtoReference = mapper + '::' + 'toDto'; diff --git a/generators/entity-server/templates/src/main/java/package/common/get_all_template.ejs b/generators/entity-server/templates/src/main/java/package/common/get_all_template.ejs index 6ca08b43d43..df9bb1aa3ef 100644 --- a/generators/entity-server/templates/src/main/java/package/common/get_all_template.ejs +++ b/generators/entity-server/templates/src/main/java/package/common/get_all_template.ejs @@ -17,8 +17,8 @@ limitations under the License. -%> <%_ - const instanceType = (dto === 'mapstruct') ? asDto(entityClass) : asEntity(entityClass); - const instanceName = (dto === 'mapstruct') ? asDto(entityInstance) : asEntity(entityInstance); + const instanceType = restClass; + const instanceName = restInstance; const mapper = entityInstance + 'Mapper'; const entityListToDtoListReference = mapper + '.' + 'toDto'; const entityToDtoReference = mapper + '::'+ 'toDto'; @@ -55,7 +55,7 @@ _%> <%_ if (viaService) { _%> return <%= entityInstance %>Service.findAll()<% if (reactive) { %>.collectList()<% } %>; <%_ } else if (dto === 'mapstruct') { _%> - <%= reactive ? 'Flux' : 'List' %><<%= asEntity(entityClass) %>> <%= entityInstancePlural %> = <%= entityInstance %>Repository.<% if (relationshipsContainEagerLoad) { %>findAllWithEagerRelationships<% } else { %>findAll<% } %>(); + <%= reactive ? 'Flux' : 'List' %><<%= persistClass %>> <%= entityInstancePlural %> = <%= entityInstance %>Repository.<% if (relationshipsContainEagerLoad) { %>findAllWithEagerRelationships<% } else { %>findAll<% } %>(); <%_ if (!reactive) { _%> return <%= entityListToDtoListReference %>(<%= entityInstancePlural %>); <%_ } else { _%> diff --git a/generators/entity-server/templates/src/main/java/package/common/get_filtered_template.ejs b/generators/entity-server/templates/src/main/java/package/common/get_filtered_template.ejs index b9020137c43..9255c7eb712 100644 --- a/generators/entity-server/templates/src/main/java/package/common/get_filtered_template.ejs +++ b/generators/entity-server/templates/src/main/java/package/common/get_filtered_template.ejs @@ -17,7 +17,7 @@ limitations under the License. -%> <% -const instanceType = (dto === 'mapstruct') ? asDto(entityClass) : asEntity(entityClass); +const instanceType = restClass; const mapper = entityInstance + 'Mapper'; const entityToDtoReference = mapper + '::' + 'toDto'; const reactiveSql = (databaseType === 'sql' && reactive); diff --git a/generators/entity-server/templates/src/main/java/package/common/get_template.ejs b/generators/entity-server/templates/src/main/java/package/common/get_template.ejs index 14e0f16c820..20445fc34fd 100644 --- a/generators/entity-server/templates/src/main/java/package/common/get_template.ejs +++ b/generators/entity-server/templates/src/main/java/package/common/get_template.ejs @@ -17,8 +17,8 @@ limitations under the License. -%> <% const optionalOrMono = (reactive === true) ? 'Mono' : 'Optional'; - const instanceType = (dto === 'mapstruct') ? `${optionalOrMono}<${asDto(entityClass)}>` : `${optionalOrMono}<${asEntity(entityClass)}>`; - const instanceName = (dto === 'mapstruct') ? asDto(entityInstance) : asEntity(entityInstance); + const instanceType = `${optionalOrMono}<${restClass}>`; + const instanceName = restInstance; const mapper = `${entityInstance}Mapper`; const entityToDtoReference = `${mapper}::toDto`; const returnPrefix = returnDirectly ? 'return' : `${instanceType} ${instanceName} =`; diff --git a/generators/entity-server/templates/src/main/java/package/common/patch_template.ejs b/generators/entity-server/templates/src/main/java/package/common/patch_template.ejs index 6c161782bb3..ff7a7075927 100644 --- a/generators/entity-server/templates/src/main/java/package/common/patch_template.ejs +++ b/generators/entity-server/templates/src/main/java/package/common/patch_template.ejs @@ -17,8 +17,8 @@ limitations under the License. -%> <% -const instanceType = (dto === 'mapstruct') ? asDto(entityClass) : asEntity(entityClass); -const instanceName = (dto === 'mapstruct') ? asDto(entityInstance) : asEntity(entityInstance); +const instanceType = restClass; +const instanceName = restInstance; const returnType = reactive ? 'Mono' : 'Optional' const mapOrFlatMap = reactive ? 'flatMap' : 'map' const returnPrefix = (isService) ? 'return' : returnType + '<' + instanceType + '> result ='; diff --git a/generators/entity-server/templates/src/main/java/package/common/search_template.ejs b/generators/entity-server/templates/src/main/java/package/common/search_template.ejs index 65584f560ed..11096789d51 100644 --- a/generators/entity-server/templates/src/main/java/package/common/search_template.ejs +++ b/generators/entity-server/templates/src/main/java/package/common/search_template.ejs @@ -17,8 +17,8 @@ limitations under the License. -%> <%_ - const instanceType = (dto === 'mapstruct') ? asDto(entityClass) : asEntity(entityClass); - const instanceName = (dto === 'mapstruct') ? asDto(entityInstance) : asEntity(entityInstance); + const instanceType = restClass; + const instanceName = restInstance; const listOrFlux = (reactive === true) ? 'Flux' : 'List'; const mapper = entityInstance + 'Mapper'; const entityToDtoReference = mapper + '::' + 'toDto'; @@ -33,7 +33,7 @@ if (pagination === 'no') { %> <%_ if (viaService) { _%> Page<<%= instanceType %>> page = <%= entityInstance %>Service.search(query, pageable); <%_ } else { _%> - Page<<%= asEntity(entityClass) %>> page = <%= entityInstance %><% if (searchEngine == 'elasticsearch') { %>Search<% } %>Repository.search(<% if (searchEngine === 'elasticsearch') { %>queryStringQuery(query)<% } else { %><%= entityClass %>.PREFIX, query<% } %>, pageable); + Page<<%= persistClass %>> page = <%= entityInstance %><% if (searchEngine == 'elasticsearch') { %>Search<% } %>Repository.search(<% if (searchEngine === 'elasticsearch') { %>queryStringQuery(query)<% } else { %><%= entityClass %>.PREFIX, query<% } %>, pageable); <%_ } _%> HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(<% if (!reactive) { %>ServletUriComponentsBuilder.fromCurrentRequest()<% } else { %>UriComponentsBuilder.fromHttpRequest(request)<% } %>, page); return ResponseEntity.ok().headers(headers).body(<% if (!viaService && dto === 'mapstruct') { %><%= entityListToDtoListReference %>(<% } %>page.getContent()<% if (!viaService && dto === 'mapstruct') { %>)<% } %>); diff --git a/generators/entity-server/templates/src/main/java/package/domain/Entity.java.ejs b/generators/entity-server/templates/src/main/java/package/domain/Entity.java.ejs index 39d1f719a4d..02df67b3c26 100644 --- a/generators/entity-server/templates/src/main/java/package/domain/Entity.java.ejs +++ b/generators/entity-server/templates/src/main/java/package/domain/Entity.java.ejs @@ -137,7 +137,7 @@ import static org.springframework.data.couchbase.core.mapping.id.GenerationStrat <%_ } _%> <%_ if (typeof javadoc == 'undefined') { _%> /** - * A <%= asEntity(entityClass) %>. + * A <%= persistClass %>. */ <%_ } else { _%> <%- formatAsClassJavadoc(javadoc) %> @@ -170,7 +170,7 @@ import static org.springframework.data.couchbase.core.mapping.id.GenerationStrat <%_ if (searchEngine === 'elasticsearch') { _%> @org.springframework.data.elasticsearch.annotations.Document(indexName = "<%= entityInstance.toLowerCase() %>") <%_ } _%> -public class <%= asEntity(entityClass) %> implements Serializable { +public class <%= persistClass %> implements Serializable { private static final long serialVersionUID = 1L; <%_ if (databaseType === 'couchbase' && !embedded) { _%> @@ -497,7 +497,7 @@ relationships.forEach((relationship, idx) => { } <%_ if (fluentMethods) { _%> - public <%= asEntity(entityClass) %> <%= primaryKey.name %>(<%= primaryKey.type %> <%= primaryKey.name %>) { + public <%= persistClass %> <%= primaryKey.name %>(<%= primaryKey.type %> <%= primaryKey.name %>) { this.<%= primaryKey.name %> = <%= primaryKey.name %>; return this; } @@ -519,9 +519,9 @@ relationships.forEach((relationship, idx) => { <%_ if (fluentMethods) { _%> <%_ if (fieldTypeBlobContent !== 'text') { _%> - public <%= asEntity(entityClass) %> <%= fieldName %>(<%= fieldType %> <%= fieldName %>) { + public <%= persistClass %> <%= fieldName %>(<%= fieldType %> <%= fieldName %>) { <%_ } else { _%> - public <%= asEntity(entityClass) %> <%= fieldName %>(String <%= fieldName %>) { + public <%= persistClass %> <%= fieldName %>(String <%= fieldName %>) { <%_ } _%> <%_ if (fieldType === 'BigDecimal' && databaseType === 'sql' && reactive) { _%> this.<%= fieldName %> = <%= fieldName %> != null ? <%= fieldName %>.stripTrailingZeros() : null; @@ -550,7 +550,7 @@ relationships.forEach((relationship, idx) => { } <%_ if (fluentMethods) { _%> - public <%= asEntity(entityClass) %> <%= fieldName %>ContentType(String <%= fieldName %>ContentType) { + public <%= persistClass %> <%= fieldName %>ContentType(String <%= fieldName %>ContentType) { this.<%= fieldName %>ContentType = <%= fieldName %>ContentType; return this; } @@ -592,7 +592,7 @@ relationships.forEach((relationship, idx) => { } <%_ if (fluentMethods) { _%> - public <%= asEntity(entityClass) %> <%= relationshipFieldNamePlural %>(Set<<%= asEntity(otherEntityNameCapitalized) %>> <%= otherEntityNamePlural %>) { + public <%= persistClass %> <%= relationshipFieldNamePlural %>(Set<<%= asEntity(otherEntityNameCapitalized) %>> <%= otherEntityNamePlural %>) { this.set<%= relationshipNameCapitalizedPlural %>(<%= otherEntityNamePlural %>); <%_ if (databaseType === 'couchbase' && !otherEntityIsEmbedded) { _%> this.<%= relationshipFieldName %>Ids = <%= otherEntityNamePlural %>.stream() @@ -602,7 +602,7 @@ relationships.forEach((relationship, idx) => { return this; } - public <%= asEntity(entityClass) %> add<%= relationshipNameCapitalized %>(<%= asEntity(otherEntityNameCapitalized) %> <%= otherEntityName %>) { + public <%= persistClass %> add<%= relationshipNameCapitalized %>(<%= asEntity(otherEntityNameCapitalized) %> <%= otherEntityName %>) { this.<%= relationshipFieldNamePlural %>.add(<%= otherEntityName %>); <%_ if (!otherEntityIsEmbedded || embedded && ownerSide === true) { _%> <%_ if (databaseType === 'couchbase' && !otherEntityIsEmbedded) { _%> @@ -622,7 +622,7 @@ relationships.forEach((relationship, idx) => { return this; } - public <%= asEntity(entityClass) %> remove<%= relationshipNameCapitalized %>(<%= asEntity(otherEntityNameCapitalized) %> <%= otherEntityName %>) { + public <%= persistClass %> remove<%= relationshipNameCapitalized %>(<%= asEntity(otherEntityNameCapitalized) %> <%= otherEntityName %>) { this.<%= relationshipFieldNamePlural %>.remove(<%= otherEntityName %>); <%_ if (!otherEntityIsEmbedded || (embedded && ownerSide === true)) { _%> <%_ if (databaseType === 'couchbase' && !otherEntityIsEmbedded) { _%> @@ -674,7 +674,7 @@ relationships.forEach((relationship, idx) => { } <%_ if (fluentMethods) { _%> - public <%= asEntity(entityClass) %> <%= relationshipFieldName %>(<%= asEntity(otherEntityNameCapitalized) %> <%= otherEntityName %>) { + public <%= persistClass %> <%= relationshipFieldName %>(<%= asEntity(otherEntityNameCapitalized) %> <%= otherEntityName %>) { this.set<%= relationshipNameCapitalized %>(<%= otherEntityName %>); <%_ if ((databaseType === 'couchbase' && !otherEntityIsEmbedded) || reactiveRelationshipWithId) { _%> this.<%= relationshipFieldName %>Id = <%= otherEntityName %> != null ? <%= otherEntityName %>.get<%= relationship.otherEntity.primaryKey.nameCapitalized %>() : null; @@ -724,11 +724,11 @@ relationships.forEach((relationship, idx) => { if (this == o) { return true; } - if (!(o instanceof <%= asEntity(entityClass) %>)) { + if (!(o instanceof <%= persistClass %>)) { return false; } <%_ if (!embedded) { _%> - return <%= primaryKey.name %> != null && <%= primaryKey.name %>.equals(((<%= asEntity(entityClass) %>) o).<%= primaryKey.name %>); + return <%= primaryKey.name %> != null && <%= primaryKey.name %>.equals(((<%= persistClass %>) o).<%= primaryKey.name %>); <%_ } else { _%> return false; <%_ } _%> @@ -743,7 +743,7 @@ relationships.forEach((relationship, idx) => { // prettier-ignore @Override public String toString() { - return "<%= asEntity(entityClass) %>{" + + return "<%= persistClass %>{" + <%_ if (!embedded) { _%> "<%= primaryKey.name %>=" + get<%= primaryKey.nameCapitalized %>() + <%_ } _%> diff --git a/generators/entity-server/templates/src/main/java/package/repository/EntityRepository.java.ejs b/generators/entity-server/templates/src/main/java/package/repository/EntityRepository.java.ejs index 4e11663e9f3..e41efdce082 100644 --- a/generators/entity-server/templates/src/main/java/package/repository/EntityRepository.java.ejs +++ b/generators/entity-server/templates/src/main/java/package/repository/EntityRepository.java.ejs @@ -18,7 +18,7 @@ -%> package <%= packageName %>.repository; -import <%= packageName %>.domain.<%= asEntity(entityClass) %>; +import <%= packageName %>.domain.<%= persistClass %>; <%_ if (relationshipsContainEagerLoad) { _%> import org.springframework.data.domain.Page; @@ -69,51 +69,51 @@ import java.util.UUID; <%_ } _%> /** - * Spring Data <%= officialDatabaseType %> repository for the <%= asEntity(entityClass) %> entity. + * Spring Data <%= officialDatabaseType %> repository for the <%= persistClass %> entity. */ <%_ if (!relationshipsContainEagerLoad) { _%> @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) %>, <%= primaryKey.type %>><% if (jpaMetamodelFiltering) { %>, JpaSpecificationExecutor<<%= asEntity(entityClass) %>><% } %><% if (searchEngine === 'couchbase') { %>, SearchCouchbaseRepository<<%= asEntity(entityClass) %>, <%= primaryKey.type %>><% } %> { +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<% } %><<%= persistClass %>, <%= primaryKey.type %>><% if (jpaMetamodelFiltering) { %>, JpaSpecificationExecutor<<%= persistClass %>><% } %><% if (searchEngine === 'couchbase') { %>, SearchCouchbaseRepository<<%= persistClass %>, <%= primaryKey.type %>><% } %> { <%_ for (const relationship of relationships) { if (relationship.relationshipType === 'many-to-one' && relationship.otherEntityName === 'user' && databaseType === 'sql') { _%> - @Query("select <%= entityInstance %> from <%= asEntity(entityClass) %> <%= entityInstance %> where <%= entityInstance %>.<%= relationship.relationshipFieldName %>.login = ?#{principal.<% if (authenticationType === 'oauth2') { %>preferredUsername<% } else { %>username<% } %>}") - List<<%= asEntity(entityClass) %>> findBy<%= relationship.relationshipNameCapitalized %>IsCurrentUser(); + @Query("select <%= entityInstance %> from <%= persistClass %> <%= entityInstance %> where <%= entityInstance %>.<%= relationship.relationshipFieldName %>.login = ?#{principal.<% if (authenticationType === 'oauth2') { %>preferredUsername<% } else { %>username<% } %>}") + List<<%= persistClass %>> findBy<%= relationship.relationshipNameCapitalized %>IsCurrentUser(); <%_ } } _%> <%_ if (relationshipsContainEagerLoad) { if (databaseType === 'sql') { _%> - @Query(value = "select distinct <%= entityInstance %> from <%= asEntity(entityClass) %> <%= entityInstance %><% + @Query(value = "select distinct <%= entityInstance %> from <%= persistClass %> <%= entityInstance %><% for (const relationship of relationships) { if (relationship.relationshipEagerLoad) { %> left join fetch <%= entityInstance %>.<%= relationship.reference.name %><% }  } %>", - countQuery = "select count(distinct <%= entityInstance %>) from <%= asEntity(entityClass) %> <%= entityInstance %>") - Page<<%= asEntity(entityClass) %>> findAllWithEagerRelationships(Pageable pageable); + countQuery = "select count(distinct <%= entityInstance %>) from <%= persistClass %> <%= entityInstance %>") + Page<<%= persistClass %>> findAllWithEagerRelationships(Pageable pageable); - @Query("select distinct <%= entityInstance %> from <%= asEntity(entityClass) %> <%= entityInstance %><% + @Query("select distinct <%= entityInstance %> from <%= persistClass %> <%= entityInstance %><% for (const relationship of relationships) { if (relationship.relationshipEagerLoad) { %> left join fetch <%= entityInstance %>.<%= relationship.reference.name %><% }  } %>") - List<<%= asEntity(entityClass) %>> findAllWithEagerRelationships(); + List<<%= persistClass %>> findAllWithEagerRelationships(); - @Query("select <%= entityInstance %> from <%= asEntity(entityClass) %> <%= entityInstance %><% + @Query("select <%= entityInstance %> from <%= persistClass %> <%= entityInstance %><% for (const relationship of relationships) { if (relationship.relationshipEagerLoad) { %> left join fetch <%= entityInstance %>.<%= relationship.reference.name %><% }  } %> where <%= entityInstance %>.id =:id") - Optional<<%= asEntity(entityClass) %>> findOneWithEagerRelationships(@Param("id") <%= primaryKey.type %> id); + Optional<<%= persistClass %>> findOneWithEagerRelationships(@Param("id") <%= primaryKey.type %> id); <%_ } else if (databaseType === 'mongodb' || databaseType === 'couchbase') { _%> @Query("<%= (databaseType === 'mongodb') ? '{}' : '#{#n1ql.selectEntity} WHERE #{#n1ql.filter}' %>") - Page<<%= asEntity(entityClass) %>> findAllWithEagerRelationships(Pageable pageable); + Page<<%= persistClass %>> findAllWithEagerRelationships(Pageable pageable); @Query("<%= (databaseType === 'mongodb') ? '{}' : '#{#n1ql.selectEntity} WHERE #{#n1ql.filter}' %>") - List<<%= asEntity(entityClass) %>> findAllWithEagerRelationships(); + List<<%= persistClass %>> findAllWithEagerRelationships(); @Query("<%- (databaseType === 'mongodb') ? "{'id': ?0}" : "#{#n1ql.selectEntity} USE KEYS $1 WHERE #{#n1ql.filter}" %>") - Optional<<%= asEntity(entityClass) %>> findOneWithEagerRelationships(<%= primaryKey.type %> id); + Optional<<%= persistClass %>> findOneWithEagerRelationships(<%= primaryKey.type %> id); <%_ } } _%> diff --git a/generators/entity-server/templates/src/main/java/package/repository/EntityRepositoryInternalImpl_reactive.java.ejs b/generators/entity-server/templates/src/main/java/package/repository/EntityRepositoryInternalImpl_reactive.java.ejs index 669b801916b..ec5dcd1115e 100644 --- a/generators/entity-server/templates/src/main/java/package/repository/EntityRepositoryInternalImpl_reactive.java.ejs +++ b/generators/entity-server/templates/src/main/java/package/repository/EntityRepositoryInternalImpl_reactive.java.ejs @@ -56,7 +56,7 @@ import org.springframework.r2dbc.core.DatabaseClient; import org.springframework.r2dbc.core.RowsFetchSpec; <%_ } _%> -import <%= packageName %>.domain.<%= asEntity(entityClass) %>; +import <%= packageName %>.domain.<%= persistClass %>; <% relationships.forEach(function(rel) { if (rel.relationshipType === 'many-to-many' && rel.ownerSide) { _%> import <%= packageName %>.domain.<%= asEntity(rel.otherEntityNameCapitalized) %>; @@ -79,7 +79,7 @@ import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; /** - * Spring Data <%= officialDatabaseType %> reactive custom repository implementation for the <%= asEntity(entityClass) %> entity. + * Spring Data <%= officialDatabaseType %> reactive custom repository implementation for the <%= persistClass %> entity. */ @SuppressWarnings("unused") class <%= entityClass %>RepositoryInternalImpl implements <%= entityClass %>RepositoryInternal { @@ -114,17 +114,17 @@ _%> } @Override - public Flux<<%= asEntity(entityClass) %>> findAllBy(Pageable pageable) { + public Flux<<%= persistClass %>> findAllBy(Pageable pageable) { return findAllBy(pageable, null); } @Override - public Flux<<%= asEntity(entityClass) %>> findAllBy(Pageable pageable, Criteria criteria) { + public Flux<<%= persistClass %>> findAllBy(Pageable pageable, Criteria criteria) { return createQuery(pageable, criteria).all(); } - RowsFetchSpec<<%= asEntity(entityClass) %>> createQuery(Pageable pageable, Criteria criteria) { - List columns = <%= asEntity(entityClass) %>SqlHelper.getColumns(entityTable, EntityManager.ENTITY_ALIAS); + RowsFetchSpec<<%= persistClass %>> createQuery(Pageable pageable, Criteria criteria) { + List columns = <%= persistClass %>SqlHelper.getColumns(entityTable, EntityManager.ENTITY_ALIAS); <%_ reactiveEagerRelations.forEach(function(rel) { _%> columns.addAll(<%= rel.otherEntityNameCapitalized %>SqlHelper.getColumns(<%= rel.relationshipName %>Table, "<%= rel.relationshipName %>")); <%_ }); _%> @@ -132,7 +132,7 @@ _%> const colName = _getJoinColumnName(rel); %> .leftOuterJoin(<%= rel.relationshipName %>Table).on(Column.create("<%= colName %>", entityTable)).equals(Column.create("id", <%= rel.relationshipName %>Table ))<%_ }); _%>; - String select = entityManager.createSelect(selectFrom, <%= asEntity(entityClass) %>.class, pageable, criteria); + String select = entityManager.createSelect(selectFrom, <%= persistClass %>.class, pageable, criteria); <%_ if (databaseType === 'sql') { _%> String alias = entityTable.getReferenceName().getReference(); String selectWhere = @@ -143,35 +143,35 @@ _%> } @Override - public Flux<<%= asEntity(entityClass) %>> findAll() { + public Flux<<%= persistClass %>> findAll() { return findAllBy(null, null); } @Override - public Mono<<%= asEntity(entityClass) %>> findById(<%= primaryKey.type %> id) { + public Mono<<%= persistClass %>> findById(<%= primaryKey.type %> id) { return createQuery(null, where("id").is(id)).one(); } <%_ if (fieldsContainOwnerManyToMany) { _%> @Override - public Mono<<%= asEntity(entityClass) %>> findOneWithEagerRelationships(Long id) { + public Mono<<%= persistClass %>> findOneWithEagerRelationships(Long id) { return findById(id); } @Override - public Flux<<%= asEntity(entityClass) %>> findAllWithEagerRelationships() { + public Flux<<%= persistClass %>> findAllWithEagerRelationships() { return findAll(); } @Override - public Flux<<%= asEntity(entityClass) %>> findAllWithEagerRelationships(Pageable page) { + public Flux<<%= persistClass %>> findAllWithEagerRelationships(Pageable page) { return findAllBy(page); } <%_ } _%> - private <%= asEntity(entityClass) %> process(Row row, RowMetadata metadata) { - <%= asEntity(entityClass) %> entity = <%= entityClass.toLowerCase() %>Mapper.apply(row, "e"); + private <%= persistClass %> process(Row row, RowMetadata metadata) { + <%= persistClass %> entity = <%= entityClass.toLowerCase() %>Mapper.apply(row, "e"); <%_ reactiveEagerRelations.forEach(function(rel) { _%> entity.set<%= rel.relationshipNameCapitalized %>(<%= rel.otherEntityNameCapitalized.toLowerCase() %>Mapper.apply(row, "<%= rel.relationshipName %>")); <%_ }); _%> @@ -179,12 +179,12 @@ _%> } @Override - public > Mono insert(S entity) { + public > Mono insert(S entity) { return entityManager.insert(entity); } @Override - public > Mono save(S entity) { + public > Mono save(S entity) { if (entity.get<%= primaryKey.nameCapitalized %>() == null) { <%_ if (isUsingMapsId) { _%> entity.set<%= primaryKey.nameCapitalized %>(entity.get<%= mapsIdAssoc.relationshipNameCapitalized %>().get<%= primaryKey.nameCapitalized %>()); @@ -201,7 +201,7 @@ _%> } @Override - public Mono update(<%= asEntity(entityClass) %> entity) { + public Mono update(<%= persistClass %> entity) { <%_ if (fields.length + reactiveEagerRelations.length > 0) { _%> //fixme is this the proper way? return r2dbcEntityTemplate.update(entity).thenReturn(1); @@ -216,11 +216,11 @@ _%> @Override public Mono deleteById(Long entityId) { return deleteRelations(entityId).then( - r2dbcEntityTemplate.delete(<%= asEntity(entityClass) %>.class).matching(query(where("id").is(entityId))).all().then() + r2dbcEntityTemplate.delete(<%= persistClass %>.class).matching(query(where("id").is(entityId))).all().then() ); } - protected > Mono updateRelations(S entity) { + protected > Mono updateRelations(S entity) { <%_ relationships.filter(function(rel) { return (rel.relationshipType === 'many-to-many' && rel.ownerSide); }).forEach(function(rel, idx) { diff --git a/generators/entity-server/templates/src/main/java/package/repository/EntityRepository_reactive.java.ejs b/generators/entity-server/templates/src/main/java/package/repository/EntityRepository_reactive.java.ejs index 0fbccaeb6f6..60afd99789b 100644 --- a/generators/entity-server/templates/src/main/java/package/repository/EntityRepository_reactive.java.ejs +++ b/generators/entity-server/templates/src/main/java/package/repository/EntityRepository_reactive.java.ejs @@ -18,7 +18,7 @@ -%> package <%= packageName %>.repository; -import <%= packageName %>.domain.<%= asEntity(entityClass) %>; +import <%= packageName %>.domain.<%= persistClass %>; <%_ if (databaseType === 'cassandra') { _%> import org.springframework.data.cassandra.repository.ReactiveCassandraRepository; <%_ } _%> @@ -60,50 +60,50 @@ import java.util.UUID; <%_ } _%> /** - * Spring Data <%= officialDatabaseType %> reactive repository for the <%= asEntity(entityClass) %> entity. + * Spring Data <%= officialDatabaseType %> reactive repository for the <%= persistClass %> entity. */ @SuppressWarnings("unused") @Repository -public interface <%= entityClass %>Repository extends <% if (databaseType === 'sql') { %>R2dbc<% } if (databaseType === 'mongodb') { %>ReactiveMongo<% } if (databaseType === 'couchbase') { %>ReactiveN1qlCouchbase<% } if (databaseType === 'neo4j') { %>ReactiveNeo4j<% } if (databaseType === 'cassandra') { %>ReactiveCassandra<% } %>Repository<<%= asEntity(entityClass) %>, <%= primaryKey.type %>><% if (searchEngine === 'couchbase') { %>, SearchCouchbaseRepository<<%= asEntity(entityClass) %>, <%= primaryKey.type %>><% } %><% if (databaseType === 'sql') { %>, <%= entityClass %>RepositoryInternal<% } %> { +public interface <%= entityClass %>Repository extends <% if (databaseType === 'sql') { %>R2dbc<% } if (databaseType === 'mongodb') { %>ReactiveMongo<% } if (databaseType === 'couchbase') { %>ReactiveN1qlCouchbase<% } if (databaseType === 'neo4j') { %>ReactiveNeo4j<% } if (databaseType === 'cassandra') { %>ReactiveCassandra<% } %>Repository<<%= persistClass %>, <%= primaryKey.type %>><% if (searchEngine === 'couchbase') { %>, SearchCouchbaseRepository<<%= persistClass %>, <%= primaryKey.type %>><% } %><% if (databaseType === 'sql') { %>, <%= entityClass %>RepositoryInternal<% } %> { <%_ if (pagination !== 'no') { _%> - Flux<<%= asEntity(entityClass) %>> findAllBy(Pageable pageable); + Flux<<%= persistClass %>> findAllBy(Pageable pageable); <%_ } _%> <%_ if (relationshipsContainEagerLoad) { _%> <%_ if (['couchbase', 'mongodb'].includes(databaseType)) { _%> @Query("<%= (databaseType === 'mongodb') ? '{}' : '#{#n1ql.selectEntity} WHERE #{#n1ql.filter}' %>") - Flux<<%= asEntity(entityClass) %>> findAllWithEagerRelationships(Pageable pageable); + Flux<<%= persistClass %>> findAllWithEagerRelationships(Pageable pageable); @Query("<%= (databaseType === 'mongodb') ? '{}' : '#{#n1ql.selectEntity} WHERE #{#n1ql.filter}' %>") - Flux<<%= asEntity(entityClass) %>> findAllWithEagerRelationships(); + Flux<<%= persistClass %>> findAllWithEagerRelationships(); @Query("<%- (databaseType === 'mongodb') ? "{'id': ?0}" : "#{#n1ql.selectEntity} USE KEYS $1 WHERE #{#n1ql.filter}" %>") - Mono<<%= asEntity(entityClass) %>> findOneWithEagerRelationships(<%= primaryKey.type %> id); + Mono<<%= persistClass %>> findOneWithEagerRelationships(<%= primaryKey.type %> id); <%_ } _%> <%_ if (databaseType === 'neo4j') { _%> - @Query("MATCH (n:<%= asEntity(entityClass) %>)<-[]-(m) RETURN n,m") - Flux<<%= asEntity(entityClass) %>> findAllWithEagerRelationships(Pageable pageable); + @Query("MATCH (n:<%= persistClass %>)<-[]-(m) RETURN n,m") + Flux<<%= persistClass %>> findAllWithEagerRelationships(Pageable pageable); - @Query("MATCH (n:<%= asEntity(entityClass) %>)<-[]-(m) RETURN n,m") - Flux<<%= asEntity(entityClass) %>> findAllWithEagerRelationships(); + @Query("MATCH (n:<%= persistClass %>)<-[]-(m) RETURN n,m") + Flux<<%= persistClass %>> findAllWithEagerRelationships(); - @Query("MATCH (e:<%= asEntity(entityClass) %> {id: $id}) RETURN e") - Mono<<%= asEntity(entityClass) %>> findOneWithEagerRelationships(<%= primaryKey.type %> id); + @Query("MATCH (e:<%= persistClass %> {id: $id}) RETURN e") + Mono<<%= persistClass %>> findOneWithEagerRelationships(<%= primaryKey.type %> id); <%_ } _%> <%_ } _%> <%_ if (databaseType === 'sql') { if (fieldsContainOwnerManyToMany) { _%> @Override - Mono<<%= asEntity(entityClass) %>> findOneWithEagerRelationships(<%= primaryKey.type %> id); + Mono<<%= persistClass %>> findOneWithEagerRelationships(<%= primaryKey.type %> id); @Override - Flux<<%= asEntity(entityClass) %>> findAllWithEagerRelationships(); + Flux<<%= persistClass %>> findAllWithEagerRelationships(); @Override - Flux<<%= asEntity(entityClass) %>> findAllWithEagerRelationships(Pageable page); + Flux<<%= persistClass %>> findAllWithEagerRelationships(Pageable page); @Override Mono deleteById(Long id); @@ -117,56 +117,56 @@ public interface <%= entityClass %>Repository extends <% if (databaseType === 's if (relationshipType === 'many-to-one' || (relationshipType === 'one-to-one' && ownerSide === true)) { _%> @Query("SELECT * FROM <%= entityTableName %> entity WHERE entity.<%= getColumnName(relationshipName) %>_id = :id") - Flux<<%= asEntity(entityClass) %>> findBy<%= relationship.relationshipNameCapitalized %>(<%= primaryKey.type %> id); + Flux<<%= persistClass %>> findBy<%= relationship.relationshipNameCapitalized %>(<%= primaryKey.type %> id); @Query("SELECT * FROM <%= entityTableName %> entity WHERE entity.<%= getColumnName(relationshipName) %>_id IS NULL") - Flux<<%= asEntity(entityClass) %>> findAllWhere<%= relationship.relationshipNameCapitalized %>IsNull(); + Flux<<%= persistClass %>> findAllWhere<%= relationship.relationshipNameCapitalized %>IsNull(); <%_ } else if (relationship.shouldWriteJoinTable) { _%> @Query("SELECT entity.* FROM <%= entityTableName %> entity JOIN <%= relationship.joinTable.name %> joinTable ON entity.id = joinTable.<%= getColumnName(name) %>_id WHERE joinTable.<%= getColumnName(relationshipName) %>_id = :id") - Flux<<%= asEntity(entityClass) %>> findBy<%= relationship.relationshipNameCapitalized %>(<%= primaryKey.type %> id); + Flux<<%= persistClass %>> findBy<%= relationship.relationshipNameCapitalized %>(<%= primaryKey.type %> id); <%_ } else if (relationshipType === 'one-to-one' && ownerSide === false) { let otherEntityRelationshipName = relationship.otherEntityRelationshipName; let otherEntityTableName = relationship.otherEntityTableName; _%> @Query("SELECT * FROM <%= entityTableName %> entity WHERE entity.id not in (select <%= getColumnName(otherEntityRelationshipName) %>_id from <%= otherEntityTableName %>)") - Flux<<%= asEntity(entityClass) %>> findAllWhere<%= relationship.relationshipNameCapitalized %>IsNull(); + Flux<<%= persistClass %>> findAllWhere<%= relationship.relationshipNameCapitalized %>IsNull(); <%_ } _%> <%_ } _%> // just to avoid having unambigous methods @Override - Flux<<%= asEntity(entityClass) %>> findAll(); + Flux<<%= persistClass %>> findAll(); @Override - Mono<<%= asEntity(entityClass) %>> findById(Long id); + Mono<<%= persistClass %>> findById(Long id); @Override - > Mono save(S entity); + > Mono save(S entity); <%_ } _%> } <%_ if (databaseType === 'sql') { _%> interface <%= entityClass %>RepositoryInternal { - > Mono insert(S entity); - > Mono save(S entity); - Mono update(<%= asEntity(entityClass) %> entity); + > Mono insert(S entity); + > Mono save(S entity); + Mono update(<%= persistClass %> entity); - Flux<<%= asEntity(entityClass) %>> findAll(); - Mono<<%= asEntity(entityClass) %>> findById(<%= primaryKey.type %> id); - Flux<<%= asEntity(entityClass) %>> findAllBy(Pageable pageable); - Flux<<%= asEntity(entityClass) %>> findAllBy(Pageable pageable, Criteria criteria); + Flux<<%= persistClass %>> findAll(); + Mono<<%= persistClass %>> findById(<%= primaryKey.type %> id); + Flux<<%= persistClass %>> findAllBy(Pageable pageable); + Flux<<%= persistClass %>> findAllBy(Pageable pageable, Criteria criteria); <%_ if (fieldsContainOwnerManyToMany) { _%> - Mono<<%= asEntity(entityClass) %>> findOneWithEagerRelationships(<%= primaryKey.type %> id); + Mono<<%= persistClass %>> findOneWithEagerRelationships(<%= primaryKey.type %> id); - Flux<<%= asEntity(entityClass) %>> findAllWithEagerRelationships(); + Flux<<%= persistClass %>> findAllWithEagerRelationships(); - Flux<<%= asEntity(entityClass) %>> findAllWithEagerRelationships(Pageable page); + Flux<<%= persistClass %>> findAllWithEagerRelationships(Pageable page); Mono deleteById(Long id); <%_ } _%> diff --git a/generators/entity-server/templates/src/main/java/package/repository/rowmapper/EntityRowMapper.java.ejs b/generators/entity-server/templates/src/main/java/package/repository/rowmapper/EntityRowMapper.java.ejs index 463b14bd5a7..3ea27ee5c33 100644 --- a/generators/entity-server/templates/src/main/java/package/repository/rowmapper/EntityRowMapper.java.ejs +++ b/generators/entity-server/templates/src/main/java/package/repository/rowmapper/EntityRowMapper.java.ejs @@ -35,7 +35,7 @@ import java.util.function.BiFunction; import org.springframework.stereotype.Service; -import <%= packageName %>.domain.<%= asEntity(entityClass) %>; +import <%= packageName %>.domain.<%= persistClass %>; <%_ Object.keys(uniqueEnums).forEach(function(element) { _%> import <%= packageName %>.domain.enumeration.<%= element %>; <%_ }); _%> @@ -44,10 +44,10 @@ import <%= packageName %>.service.ColumnConverter; import io.r2dbc.spi.Row; /** - * Converter between {@link Row} to {@link <%= asEntity(entityClass) %>}, with proper type conversions. + * Converter between {@link Row} to {@link <%= persistClass %>}, with proper type conversions. */ @Service -public class <%= entityClass %>RowMapper implements BiFunction> { +public class <%= entityClass %>RowMapper implements BiFunction> { private final ColumnConverter converter; public <%= entityClass %>RowMapper(ColumnConverter converter) { this.converter = converter; @@ -55,11 +55,11 @@ public class <%= entityClass %>RowMapper implements BiFunction} stored in the database. + * @return the {@link <%= persistClass %>} stored in the database. */ @Override - public <%= asEntity(entityClass) %> apply(Row row, String prefix) { - <%= asEntity(entityClass) %> entity = new <%= asEntity(entityClass) %>(); + public <%= persistClass %> apply(Row row, String prefix) { + <%= persistClass %> entity = new <%= persistClass %>(); <%_ fields.forEach(function(field) { let fieldType = field.fieldType; if (field.fieldTypeBlobContent === 'text') { diff --git a/generators/entity-server/templates/src/main/java/package/repository/search/EntitySearchRepository.java.ejs b/generators/entity-server/templates/src/main/java/package/repository/search/EntitySearchRepository.java.ejs index 368dcb62589..370df229d4e 100644 --- a/generators/entity-server/templates/src/main/java/package/repository/search/EntitySearchRepository.java.ejs +++ b/generators/entity-server/templates/src/main/java/package/repository/search/EntitySearchRepository.java.ejs @@ -18,7 +18,7 @@ -%> package <%= packageName %>.repository.search; -import <%= packageName %>.domain.<%= asEntity(entityClass) %>; +import <%= packageName %>.domain.<%= persistClass %>; <%_ if (reactive) { _%> <%_ if (pagination !== 'no') { _%> import org.springframework.data.domain.Pageable; @@ -41,9 +41,9 @@ import static org.elasticsearch.index.query.QueryBuilders.queryStringQuery; <%_ } _%> /** - * Spring Data Elasticsearch repository for the {@link <%= asEntity(entityClass) %>} entity. + * Spring Data Elasticsearch repository for the {@link <%= persistClass %>} entity. */ -public interface <%= entityClass %>SearchRepository extends <% if (reactive) {%>Reactive<% } %>ElasticsearchRepository<<%= asEntity(entityClass) %>, <%= primaryKey.type %>><% if (reactive) {%>, <%= entityClass %>SearchRepositoryInternal<% } %> { +public interface <%= entityClass %>SearchRepository extends <% if (reactive) {%>Reactive<% } %>ElasticsearchRepository<<%= persistClass %>, <%= primaryKey.type %>><% if (reactive) {%>, <%= entityClass %>SearchRepositoryInternal<% } %> { } <%_ if (reactive) { _%> diff --git a/generators/entity-server/templates/src/main/java/package/service/EntityQueryService.java.ejs b/generators/entity-server/templates/src/main/java/package/service/EntityQueryService.java.ejs index d3d5895e005..52e8e52e6c8 100644 --- a/generators/entity-server/templates/src/main/java/package/service/EntityQueryService.java.ejs +++ b/generators/entity-server/templates/src/main/java/package/service/EntityQueryService.java.ejs @@ -20,8 +20,8 @@ package <%= packageName %>.service; <%_ const serviceClassName = entityClass + 'QueryService'; -const instanceType = (dto === 'mapstruct') ? asDto(entityClass) : asEntity(entityClass); -const instanceName = (dto === 'mapstruct') ? asDto(entityInstance) : asEntity(entityInstance); +const instanceType = restClass; +const instanceName = restInstance; const mapper = entityInstance + 'Mapper'; const dtoToEntity = mapper + '.'+ 'toEntity'; const entityToDto = mapper + '.'+ 'toDto'; @@ -44,25 +44,25 @@ import org.springframework.transaction.annotation.Transactional; import tech.jhipster.service.QueryService; -import <%= packageName %>.domain.<%= asEntity(entityClass) %>; +import <%= packageName %>.domain.<%= persistClass %>; import <%= packageName %>.domain.*; // for static metamodels import <%= packageName %>.repository.<%= entityClass %>Repository;<% if (searchEngine === 'elasticsearch') { %> import <%= packageName %>.repository.search.<%= entityClass %>SearchRepository;<% } %> import <%= packageName %>.service.criteria.<%= entityClass %>Criteria; <%_ if (dto === 'mapstruct') { _%> -import <%= packageName %>.service.dto.<%= asDto(entityClass) %>; +import <%= packageName %>.service.dto.<%= dtoClass %>; import <%= packageName %>.service.mapper.<%= entityClass %>Mapper; <%_ } _%> /** - * Service for executing complex queries for {@link <%= asEntity(entityClass) %>} entities in the database. + * Service for executing complex queries for {@link <%= persistClass %>} entities in the database. * The main input is a {@link <%= entityClass %>Criteria} which gets converted to {@link Specification}, * in a way that all the filters must apply. * It returns a {@link List} of {@link <%= instanceType %>} or a {@link Page} of {@link <%= instanceType %>} which fulfills the criteria. */ @Service<% if (databaseType === 'sql') { %> @Transactional(readOnly = true)<% } %> -public class <%= serviceClassName %> extends QueryService<<%= asEntity(entityClass) %>> { +public class <%= serviceClassName %> extends QueryService<<%= persistClass %>> { private final Logger log = LoggerFactory.getLogger(<%= serviceClassName %>.class); <%- include('../common/inject_template', {viaService: false, constructorName: serviceClassName, queryService: false, isUsingMapsId: false, mapsIdAssoc: null, isController: false}); -%> @@ -75,7 +75,7 @@ public class <%= serviceClassName %> extends QueryService<<%= asEntity(entityCla @Transactional(readOnly = true) public List<<%= instanceType %>> findByCriteria(<%= criteria %> criteria) { log.debug("find by criteria : {}", criteria); - final Specification<<%= asEntity(entityClass) %>> specification = createSpecification(criteria); + final Specification<<%= persistClass %>> specification = createSpecification(criteria); <%_ if (dto === 'mapstruct') { _%> return <%= entityListToDto %>(<%= repository %>.findAll(specification)); <%_ } else { _%> @@ -92,7 +92,7 @@ public class <%= serviceClassName %> extends QueryService<<%= asEntity(entityCla @Transactional(readOnly = true) public Page<<%= instanceType %>> findByCriteria(<%= criteria %> criteria, Pageable page) { log.debug("find by criteria : {}, page: {}", criteria, page); - final Specification<<%= asEntity(entityClass) %>> specification = createSpecification(criteria); + final Specification<<%= persistClass %>> specification = createSpecification(criteria); <%_ if (dto === 'mapstruct') { _%> return <%= repository %>.findAll(specification, page) .map(<%= entityToDtoReference %>); @@ -109,7 +109,7 @@ public class <%= serviceClassName %> extends QueryService<<%= asEntity(entityCla @Transactional(readOnly = true) public long countByCriteria(<%= criteria %> criteria) { log.debug("count by criteria : {}", criteria); - final Specification<<%= asEntity(entityClass) %>> specification = createSpecification(criteria); + final Specification<<%= persistClass %>> specification = createSpecification(criteria); return <%= repository %>.count(specification); } @@ -118,18 +118,18 @@ public class <%= serviceClassName %> extends QueryService<<%= asEntity(entityCla * @param criteria The object which holds all the filters, which the entities should match. * @return the matching {@link Specification} of the entity. */ - protected Specification<<%= asEntity(entityClass) %>> createSpecification(<%= criteria %> criteria) { - Specification<<%= asEntity(entityClass) %>> specification = Specification.where(null); + protected Specification<<%= persistClass %>> createSpecification(<%= criteria %> criteria) { + Specification<<%= persistClass %>> specification = Specification.where(null); if (criteria != null) { if (criteria.get<%= primaryKey.nameCapitalized %>() != null) { - specification = specification.and(<%= getSpecificationBuilder(primaryKey.type) %>(criteria.get<%= primaryKey.nameCapitalized %>(), <%= asEntity(entityClass) %>_.<%= primaryKey.name %>)); + specification = specification.and(<%= getSpecificationBuilder(primaryKey.type) %>(criteria.get<%= primaryKey.nameCapitalized %>(), <%= persistClass %>_.<%= primaryKey.name %>)); } <%_ fields.forEach((field) => { if (field.id) return; if (isFilterableType(field.fieldType)) { _%> if (criteria.get<%= field.fieldInJavaBeanMethod %>() != null) { - specification = specification.and(<%= getSpecificationBuilder(field.fieldType) %>(criteria.get<%= field.fieldInJavaBeanMethod %>(), <%= asEntity(entityClass) %>_.<%= field.fieldName %>)); + specification = specification.and(<%= getSpecificationBuilder(field.fieldType) %>(criteria.get<%= field.fieldInJavaBeanMethod %>(), <%= persistClass %>_.<%= field.fieldName %>)); } <%_ } }); @@ -138,7 +138,7 @@ public class <%= serviceClassName %> extends QueryService<<%= asEntity(entityCla const metamodelFieldName = (relationship.relationshipType === 'many-to-many' || relationship.relationshipType === 'one-to-many') ? relationship.relationshipFieldNamePlural : relationship.relationshipFieldName; _%> if (criteria.get<%= relationship.relationshipNameCapitalized %>Id() != null) { specification = specification.and(buildSpecification(criteria.get<%= relationship.relationshipNameCapitalized %>Id(), - root -> root.join(<%= asEntity(entityClass) %>_.<%= metamodelFieldName %>, JoinType.LEFT).get(<%= asEntity(relationship.otherEntityNameCapitalized) %>_.<%= relationship.otherEntity.primaryKey.name %>))); + root -> root.join(<%= persistClass %>_.<%= metamodelFieldName %>, JoinType.LEFT).get(<%= asEntity(relationship.otherEntityNameCapitalized) %>_.<%= relationship.otherEntity.primaryKey.name %>))); } <%_ }); // forEach _%> diff --git a/generators/entity-server/templates/src/main/java/package/service/EntityService.java.ejs b/generators/entity-server/templates/src/main/java/package/service/EntityService.java.ejs index 330621fb8b9..88e321c7d8f 100644 --- a/generators/entity-server/templates/src/main/java/package/service/EntityService.java.ejs +++ b/generators/entity-server/templates/src/main/java/package/service/EntityService.java.ejs @@ -19,16 +19,16 @@ package <%= packageName %>.service; <%_ -const instanceType = (dto === 'mapstruct') ? asDto(entityClass) : asEntity(entityClass); -const instanceName = (dto === 'mapstruct') ? asDto(entityInstance) : asEntity(entityInstance); +const instanceType = restClass; +const instanceName = restInstance; const optionalOrMono = (reactive === true) ? 'Mono' : 'Optional'; const listOrFlux = (reactive === true) ? 'Flux' : 'List'; const pageOrFlux = (reactive === true) ? 'Flux' : 'Page'; _%> <%_ if (dto === 'mapstruct') { _%> -import <%= packageName %>.service.dto.<%= asDto(entityClass) %>; +import <%= packageName %>.service.dto.<%= dtoClass %>; <%_ } else { _%> -import <%= packageName %>.domain.<%= asEntity(entityClass) %>; +import <%= packageName %>.domain.<%= persistClass %>; <%_ } _%> <%_ if (pagination !== 'no' || relationshipsContainEagerLoad) { _%> @@ -53,7 +53,7 @@ import java.util.UUID; <%_ } _%> /** - * Service Interface for managing {@link <% if (dto === 'mapstruct') { %><%= packageName %>.domain.<% } %><%= asEntity(entityClass) %>}. + * Service Interface for managing {@link <% if (dto === 'mapstruct') { %><%= packageName %>.domain.<% } %><%= persistClass %>}. */ public interface <%= entityClass %>Service { @@ -82,7 +82,7 @@ public interface <%= entityClass %>Service { <% if (pagination !== 'no') { %><%= pageOrFlux %><<%= instanceType %><% } else { %><%= listOrFlux %><<%= instanceType %><% } %>> findAll(<% if (pagination !== 'no') { %>Pageable pageable<% } %>); <% for (const relationship of relationships) { if (relationship.relationshipType === 'one-to-one' && relationship.ownerSide !== true) { -%> /** - * Get all the <%= asDto(entityClass) %> where <%= relationship.relationshipNameCapitalized %> is {@code null}. + * Get all the <%= restClass %> where <%= relationship.relationshipNameCapitalized %> is {@code null}. * * @return the {@link <%= listOrFlux %>} of entities. */ diff --git a/generators/entity-server/templates/src/main/java/package/service/criteria/EntityCriteria.java.ejs b/generators/entity-server/templates/src/main/java/package/service/criteria/EntityCriteria.java.ejs index 6f51bb6fffd..06ffbf87e99 100644 --- a/generators/entity-server/templates/src/main/java/package/service/criteria/EntityCriteria.java.ejs +++ b/generators/entity-server/templates/src/main/java/package/service/criteria/EntityCriteria.java.ejs @@ -68,7 +68,7 @@ filterVariables.push({ filterType : oauthAwareReferenceFilterType, }); _%> /** - * Criteria class for the {@link <%= packageName %>.domain.<%= asEntity(entityClass) %>} entity. This class is used + * Criteria class for the {@link <%= packageName %>.domain.<%= persistClass %>} entity. This class is used * in {@link <%= packageName %>.web.rest.<%= entityClass %>Resource} to receive all the possible filtering options from * the Http GET request parameters. * For example the following could be a valid request: diff --git a/generators/entity-server/templates/src/main/java/package/service/dto/EntityDTO.java.ejs b/generators/entity-server/templates/src/main/java/package/service/dto/EntityDTO.java.ejs index 4b4484f28cc..2aea993e2f8 100644 --- a/generators/entity-server/templates/src/main/java/package/service/dto/EntityDTO.java.ejs +++ b/generators/entity-server/templates/src/main/java/package/service/dto/EntityDTO.java.ejs @@ -61,12 +61,12 @@ import <%= packageName %>.domain.enumeration.<%= element %>; <%_ }); _%> /** - * A DTO for the {@link <%= packageName %>.domain.<%= asEntity(entityClass) %>} entity. + * A DTO for the {@link <%= packageName %>.domain.<%= persistClass %>} entity. */ <%_ if (typeof javadoc !== 'undefined') { _%> @ApiModel(description = "<%- formatAsApiDescription(javadoc) %>") <%_ } _%> -public class <%= asDto(entityClass) %> implements Serializable { +public class <%= dtoClass %> implements Serializable { <%_ for (reference of dtoReferences) { if (typeof reference.doc !== 'undefined') { @@ -146,16 +146,16 @@ _%> if (this == o) { return true; } - if (!(o instanceof <%= asDto(entityClass) %>)) { + if (!(o instanceof <%= dtoClass %>)) { return false; } <%_ if (!embedded) { _%> - <%= asDto(entityClass) %> <%= asDto(entityInstance) %> = (<%= asDto(entityClass) %>) o; + <%= dtoClass %> <%= dtoInstance %> = (<%= dtoClass %>) o; if (<%- idNames.map(n => `this.${n} == null`).join(' && ') %>){ return false; } - return <%- idNames.map(n => `Objects.equals(this.${n}, ${asDto(entityInstance)}.${n})`).join(' &&\n ') %>; + return <%- idNames.map(n => `Objects.equals(this.${n}, ${dtoInstance}.${n})`).join(' &&\n ') %>; <%_ } else { _%> return false; <%_ } _%> @@ -173,7 +173,7 @@ _%> // prettier-ignore @Override public String toString() { - return "<%= asDto(entityClass) %>{" + + return "<%= dtoClass %>{" + <%_ for ([idx, reference] of dtoReferences.entries()) { const isNumeric = reference.type && ['integer', 'long', 'float', 'double', 'bigdecimal'].includes(reference.type.toLowerCase()); _%> "<%= idx === 0 ? '' : ', ' %><%= reference.name %>=<% if (! isNumeric) { %>'<% } %>" + <%= buildJavaGet(reference) %> <% if (! isNumeric) { %>+ "'" <% } %>+ diff --git a/generators/entity-server/templates/src/main/java/package/service/impl/EntityServiceImpl.java.ejs b/generators/entity-server/templates/src/main/java/package/service/impl/EntityServiceImpl.java.ejs index 7a0c58cc037..3a92e90b309 100644 --- a/generators/entity-server/templates/src/main/java/package/service/impl/EntityServiceImpl.java.ejs +++ b/generators/entity-server/templates/src/main/java/package/service/impl/EntityServiceImpl.java.ejs @@ -20,8 +20,8 @@ package <%= packageName %>.service<% if (service === 'serviceImpl') { %>.impl<% <%_ const serviceClassName = service === 'serviceImpl' ? entityClass + 'ServiceImpl' : entityClass + 'Service'; -const instanceType = (dto === 'mapstruct') ? asDto(entityClass) : asEntity(entityClass); -const instanceName = (dto === 'mapstruct') ? asDto(entityInstance) : asEntity(entityInstance); +const instanceType = restClass; +const instanceName = restInstance; const optionalOrMono = (reactive === true) ? 'Mono' : 'Optional'; const listOrFlux = (reactive === true) ? 'Flux' : 'List'; const pageOrFlux = (reactive === true) ? 'Flux' : 'Page'; @@ -36,7 +36,7 @@ _%> <%_ if (service === 'serviceImpl') { _%> import <%= packageName %>.service.<%= entityClass %>Service; <%_ } _%> -import <%= packageName %>.domain.<%= asEntity(entityClass) %>; +import <%= packageName %>.domain.<%= persistClass %>; import <%= packageName %>.repository.<%= entityClass %>Repository; <%_ if (isUsingMapsId === true) { _%> import <%= packageName %>.repository.<%= mapsIdAssoc.otherEntityNameCapitalized %>Repository; @@ -45,7 +45,7 @@ import <%= packageName %>.repository.<%= mapsIdAssoc.otherEntityNameCapitalized import <%= packageName %>.repository.search.<%= entityClass %>SearchRepository; <%_ } _%> <%_ if (dto === 'mapstruct') { _%> -import <%= packageName %>.service.dto.<%= asDto(entityClass) %>; +import <%= packageName %>.service.dto.<%= dtoClass %>; import <%= packageName %>.service.mapper.<%= entityClass %>Mapper; <%_ } _%> import org.slf4j.Logger; @@ -90,7 +90,7 @@ import static org.elasticsearch.index.query.QueryBuilders.*; <%_ } _%> /** - * Service Implementation for managing {@link <%= asEntity(entityClass) %>}. + * Service Implementation for managing {@link <%= persistClass %>}. */ @Service<% if (databaseType === 'sql') { %> @Transactional<% } %> diff --git a/generators/entity-server/templates/src/main/java/package/service/mapper/EntityMapper.java.ejs b/generators/entity-server/templates/src/main/java/package/service/mapper/EntityMapper.java.ejs index aa87038f9cc..be67c7f4146 100644 --- a/generators/entity-server/templates/src/main/java/package/service/mapper/EntityMapper.java.ejs +++ b/generators/entity-server/templates/src/main/java/package/service/mapper/EntityMapper.java.ejs @@ -24,7 +24,7 @@ let uuidMapMethod = dtoReferences.some(reference => reference.valueReference && let byteMapMethod = dtoReferences.some(reference => reference.valueReference && reference.valueReference.field && reference.valueReference.field.fieldType === 'byte[]'); for (reference of dtoReferences) { // if the entity is mapped twice, we should implement the mapping once - if (reference.relationship && !reference.relationship.otherEntity.embedded && !existingMappings.includes(reference.name) && asEntity(reference.relationship.otherEntityNameCapitalized) !== asEntity(entityClass)) { + if (reference.relationship && !reference.relationship.otherEntity.embedded && !existingMappings.includes(reference.name) && asEntity(reference.relationship.otherEntityNameCapitalized) !== persistClass) { existingMappings.push(reference.relationship.otherEntity.entityNameCapitalized); } } @@ -39,7 +39,7 @@ import java.util.Set; <%_ } _%> import <%= packageName %>.domain.*; -import <%= packageName %>.service.dto.<%= asDto(entityClass) %>; +import <%= packageName %>.service.dto.<%= dtoClass %>; import org.mapstruct.*; <%_ if (uuidMapMethod) { _%> @@ -49,10 +49,10 @@ import java.util.UUID; <%_ } _%> /** - * Mapper for the entity {@link <%= asEntity(entityClass) %>} and its DTO {@link <%= asDto(entityClass) %>}. + * Mapper for the entity {@link <%= persistClass %>} and its DTO {@link <%= dtoClass %>}. */ @Mapper(componentModel = "spring", uses = {<%= [...new Set(existingMappings.map(otherEntityNameCapitalized => otherEntityNameCapitalized + 'Mapper.class'))].join(', ') %>}) -public interface <%= entityClass %>Mapper extends EntityMapper<<%= asDto(entityClass) %>, <%= asEntity(entityClass) %>> { +public interface <%= entityClass %>Mapper extends EntityMapper<<%= dtoClass %>, <%= persistClass %>> { <%_ /***** Basic dto mapping *****/ if (!embedded) { var renMapAnotEnt = false; //Render Mapping Annotation during Entity to DTO conversion? @@ -72,7 +72,7 @@ public interface <%= entityClass %>Mapper extends EntityMapper<<%= asDto(entityC @Mapping( target = "<%= reference.name %>", expression = "<%- reference.field.mapstructExpression %>") <%_ } _%> <%_ if (renMapAnotEnt === true) { _%> - <%= asDto(entityClass) %> toDto(<%= asEntity(entityClass) %> s); + <%= dtoClass %> toDto(<%= persistClass %> s); <%_ } %> <%_ } %> <%_ /***** Id mapping *****/ @@ -88,7 +88,7 @@ public interface <%= entityClass %>Mapper extends EntityMapper<<%= asDto(entityC @Mapping(target = "<%= reference.name %>", source = "<%= reference.name %>") <%_ } _%> <%_ if (renMapAnotEnt === true) { _%> - <%= asDto(entityClass) %> toDtoId(<%= asEntity(entityClass) %> <%= asEntity(entityInstance) %>); + <%= dtoClass %> toDtoId(<%= persistClass %> <%= persistInstance %>); <%_ } _%> <%_ } _%> <%_ if (otherIdReferences.some(r => r.collection)) { _%> @@ -101,7 +101,7 @@ public interface <%= entityClass %>Mapper extends EntityMapper<<%= asDto(entityC @Mapping(target = "<%= reference.name %>", source = "<%= reference.name %>") <%_ } _%> <%_ if (renMapAnotEnt === true) { _%> - Set<<%= asDto(entityClass) %>> toDtoIdSet(Set<<%= asEntity(entityClass) %>> <%= asEntity(entityInstance) %>); + Set<<%= dtoClass %>> toDtoIdSet(Set<<%= persistClass %>> <%= persistInstance %>); <%_ } _%> <%_ } _%> <%_ } _%> @@ -126,7 +126,7 @@ public interface <%= entityClass %>Mapper extends EntityMapper<<%= asDto(entityC <%_ } _%> <%_ } _%> <%_ if (renMapAnotDto === true) { _%> - <%= asEntity(entityClass) %> toEntity(<%= asDto(entityClass) %> <%= asDto(entityInstance) %>); + <%= persistClass %> toEntity(<%= dtoClass %> <%= dtoInstance %>); <%_ } _%> <%_ /***** Add filtered backreference *****/ const addedMappers = []; @@ -136,8 +136,8 @@ public interface <%= entityClass %>Mapper extends EntityMapper<<%= asDto(entityC const mapperName = otherReference.relationship.otherEntityField + (collection ? 'Set' : ''); if (addedMappers.includes(mapperName)) continue; addedMappers.push(mapperName); - const backReferenceDtoClass = collection ? `Set<${asDto(entityClass)}>` : asDto(entityClass); - const backReferenceEntityClass = collection ? `Set<${asEntity(entityClass)}>` : asEntity(entityClass); _%> + const backReferenceDtoClass = collection ? `Set<${dtoClass}>` : dtoClass; + const backReferenceEntityClass = collection ? `Set<${persistClass}>` : persistClass; _%> @Named("<%= mapperName %>") @BeanMapping(ignoreByDefault = true) @@ -147,7 +147,7 @@ public interface <%= entityClass %>Mapper extends EntityMapper<<%= asDto(entityC <%_ if (otherReference.relationship.relatedField && !otherReference.relationship.relatedField.id) { _%> @Mapping(target = "<%= otherReference.relationship.relatedField.reference.name %>", source = "<%= otherReference.relationship.relatedField.reference.name %>") <%_ } _%> - <%- backReferenceDtoClass %> toDto<%= _.upperFirst(mapperName) %>(<%- backReferenceEntityClass %> <%= asEntity(entityInstance) %>); + <%- backReferenceDtoClass %> toDto<%= _.upperFirst(mapperName) %>(<%- backReferenceEntityClass %> <%= persistInstance %>); <%_ }; _%> <%_ if (uuidMapMethod) { _%> diff --git a/generators/entity-server/templates/src/main/java/package/web/rest/EntityResource.java.ejs b/generators/entity-server/templates/src/main/java/package/web/rest/EntityResource.java.ejs index dbfd1a731d6..8a1280cf075 100644 --- a/generators/entity-server/templates/src/main/java/package/web/rest/EntityResource.java.ejs +++ b/generators/entity-server/templates/src/main/java/package/web/rest/EntityResource.java.ejs @@ -30,7 +30,7 @@ for (const relationship of relationships) { } _%> <%_ if (dto !== 'mapstruct' || service === 'no') { _%> -import <%= packageName %>.domain.<%= asEntity(entityClass) %>; +import <%= packageName %>.domain.<%= persistClass %>; <%_ } _%> import <%= packageName %>.repository.<%= entityClass %>Repository; <%_ if (service !== 'no') { _%> @@ -48,7 +48,7 @@ import <%= packageName %>.repository.UserRepository; <%_ } _%> import <%= packageName %>.web.rest.errors.BadRequestAlertException; <%_ if (dto === 'mapstruct') { _%> -import <%= packageName %>.service.dto.<%= asDto(entityClass) %>; +import <%= packageName %>.service.dto.<%= dtoClass %>; <%_ if (service === 'no') { _%> import <%= packageName %>.service.mapper.<%= entityClass %>Mapper; <%_ } _%> @@ -134,7 +134,7 @@ import static org.elasticsearch.index.query.QueryBuilders.*; <%_ } _%> /** - * REST controller for managing {@link <%= packageName %>.domain.<%= asEntity(entityClass) %>}. + * REST controller for managing {@link <%= packageName %>.domain.<%= persistClass %>}. */ @RestController @RequestMapping("/api") @@ -156,8 +156,8 @@ public class <%= entityClass %>Resource { private String applicationName; <%_ } _%> <%_ - const instanceType = (dto === 'mapstruct') ? asDto(entityClass) : asEntity(entityClass); - const instanceName = (dto === 'mapstruct') ? asDto(entityInstance) : asEntity(entityInstance); + const instanceType = restClass; + const instanceName = restInstance; const mapper = entityInstance + 'Mapper'; const entityToDtoReference = mapper + '::' + 'toDto'; _%><%- include('../../common/inject_template', {viaService: viaService, constructorName: entityClass + 'Resource', queryService: jpaMetamodelFiltering, isUsingMapsId: isUsingMapsId, mapsIdAssoc: mapsIdAssoc, isController: true}); -%> diff --git a/generators/entity-server/templates/src/test/java/package/domain/EntityTest.java.ejs b/generators/entity-server/templates/src/test/java/package/domain/EntityTest.java.ejs index 5550bf41470..943402574bd 100644 --- a/generators/entity-server/templates/src/test/java/package/domain/EntityTest.java.ejs +++ b/generators/entity-server/templates/src/test/java/package/domain/EntityTest.java.ejs @@ -25,21 +25,21 @@ import <%= packageName %>.web.rest.TestUtil; import java.util.UUID; <%_ } _%> -class <%= asEntity(entityClass) %>Test { +class <%= persistClass %>Test { @Test void equalsVerifier() throws Exception { - TestUtil.equalsVerifier(<%= asEntity(entityClass) %>.class); + TestUtil.equalsVerifier(<%= persistClass %>.class); <%_if (!embedded) { _%> - <%= asEntity(entityClass) %> <%= asEntity(entityInstance) %>1 = new <%= asEntity(entityClass) %>(); - <%= asEntity(entityInstance) %>1.set<%= primaryKey.nameCapitalized %>(<% if (primaryKey.type === 'Long') { %>1L<% } else if (primaryKey.type === 'String') { %>"id1"<% } else if (primaryKey.type === 'UUID') { %>UUID.randomUUID()<% } %>); - <%= asEntity(entityClass) %> <%= asEntity(entityInstance) %>2 = new <%= asEntity(entityClass) %>(); - <%= asEntity(entityInstance) %>2.set<%= primaryKey.nameCapitalized %>(<%= asEntity(entityInstance) %>1.get<%= primaryKey.nameCapitalized %>()); - assertThat(<%= asEntity(entityInstance) %>1).isEqualTo(<%= asEntity(entityInstance) %>2); - <%= asEntity(entityInstance) %>2.set<%= primaryKey.nameCapitalized %>(<% if (primaryKey.type === 'Long') { %>2L<% } else if (primaryKey.type === 'String') { %>"id2"<% } else if (primaryKey.type === 'UUID') { %>UUID.randomUUID()<% } %>); - assertThat(<%= asEntity(entityInstance) %>1).isNotEqualTo(<%= asEntity(entityInstance) %>2); - <%= asEntity(entityInstance) %>1.set<%= primaryKey.nameCapitalized %>(null); - assertThat(<%= asEntity(entityInstance) %>1).isNotEqualTo(<%= asEntity(entityInstance) %>2); + <%= persistClass %> <%= persistInstance %>1 = new <%= persistClass %>(); + <%= persistInstance %>1.set<%= primaryKey.nameCapitalized %>(<% if (primaryKey.type === 'Long') { %>1L<% } else if (primaryKey.type === 'String') { %>"id1"<% } else if (primaryKey.type === 'UUID') { %>UUID.randomUUID()<% } %>); + <%= persistClass %> <%= persistInstance %>2 = new <%= persistClass %>(); + <%= persistInstance %>2.set<%= primaryKey.nameCapitalized %>(<%= persistInstance %>1.get<%= primaryKey.nameCapitalized %>()); + assertThat(<%= persistInstance %>1).isEqualTo(<%= persistInstance %>2); + <%= persistInstance %>2.set<%= primaryKey.nameCapitalized %>(<% if (primaryKey.type === 'Long') { %>2L<% } else if (primaryKey.type === 'String') { %>"id2"<% } else if (primaryKey.type === 'UUID') { %>UUID.randomUUID()<% } %>); + assertThat(<%= persistInstance %>1).isNotEqualTo(<%= persistInstance %>2); + <%= persistInstance %>1.set<%= primaryKey.nameCapitalized %>(null); + assertThat(<%= persistInstance %>1).isNotEqualTo(<%= persistInstance %>2); <%_} _%> } } diff --git a/generators/entity-server/templates/src/test/java/package/service/dto/EntityDTOTest.java.ejs b/generators/entity-server/templates/src/test/java/package/service/dto/EntityDTOTest.java.ejs index e88d99fb83e..0bf83847628 100644 --- a/generators/entity-server/templates/src/test/java/package/service/dto/EntityDTOTest.java.ejs +++ b/generators/entity-server/templates/src/test/java/package/service/dto/EntityDTOTest.java.ejs @@ -32,22 +32,22 @@ if (!embedded) { import java.util.UUID; <%_ } _%> -class <%= asDto(entityClass) %>Test { +class <%= dtoClass %>Test { @Test void dtoEqualsVerifier() throws Exception { - TestUtil.equalsVerifier(<%= asDto(entityClass) %>.class); + TestUtil.equalsVerifier(<%= dtoClass %>.class); <%_if (!embedded) { _%> - <%= asDto(entityClass) %> <%= asDto(entityInstance) %>1 = new <%= asDto(entityClass) %>(); - <%= asDto(entityInstance) %>1.set<%= primaryKey.nameCapitalized %>(<%- id1 %>); - <%= asDto(entityClass) %> <%= asDto(entityInstance) %>2 = new <%= asDto(entityClass) %>(); - assertThat(<%= asDto(entityInstance) %>1).isNotEqualTo(<%= asDto(entityInstance) %>2); - <%= asDto(entityInstance) %>2.set<%= primaryKey.nameCapitalized %>(<%= asDto(entityInstance) %>1.get<%= primaryKey.nameCapitalized %>()); - assertThat(<%= asDto(entityInstance) %>1).isEqualTo(<%= asDto(entityInstance) %>2); - <%= asDto(entityInstance) %>2.set<%= primaryKey.nameCapitalized %>(<%- id2 %>); - assertThat(<%= asDto(entityInstance) %>1).isNotEqualTo(<%= asDto(entityInstance) %>2); - <%= asDto(entityInstance) %>1.set<%= primaryKey.nameCapitalized %>(null); - assertThat(<%= asDto(entityInstance) %>1).isNotEqualTo(<%= asDto(entityInstance) %>2); + <%= dtoClass %> <%= dtoInstance %>1 = new <%= dtoClass %>(); + <%= dtoInstance %>1.set<%= primaryKey.nameCapitalized %>(<%- id1 %>); + <%= dtoClass %> <%= dtoInstance %>2 = new <%= dtoClass %>(); + assertThat(<%= dtoInstance %>1).isNotEqualTo(<%= dtoInstance %>2); + <%= dtoInstance %>2.set<%= primaryKey.nameCapitalized %>(<%= dtoInstance %>1.get<%= primaryKey.nameCapitalized %>()); + assertThat(<%= dtoInstance %>1).isEqualTo(<%= dtoInstance %>2); + <%= dtoInstance %>2.set<%= primaryKey.nameCapitalized %>(<%- id2 %>); + assertThat(<%= dtoInstance %>1).isNotEqualTo(<%= dtoInstance %>2); + <%= dtoInstance %>1.set<%= primaryKey.nameCapitalized %>(null); + assertThat(<%= dtoInstance %>1).isNotEqualTo(<%= dtoInstance %>2); <%_} _%> } } diff --git a/generators/entity-server/templates/src/test/java/package/web/rest/EntityResourceIT.java.ejs b/generators/entity-server/templates/src/test/java/package/web/rest/EntityResourceIT.java.ejs index 16f4f8be923..16aea70f7a4 100644 --- a/generators/entity-server/templates/src/test/java/package/web/rest/EntityResourceIT.java.ejs +++ b/generators/entity-server/templates/src/test/java/package/web/rest/EntityResourceIT.java.ejs @@ -64,7 +64,7 @@ if (databaseType === 'sql' && reactive) { createEntityPrefix = 'em.insert('; createEntityPostfix = ').block()'; } -let idValue = `${asEntity(entityInstance)}.get${primaryKey.nameCapitalized}()`; +let idValue = `${persistInstance}.get${primaryKey.nameCapitalized}()`; if (primaryKey.type === 'Long') { idValue = idValue + '.intValue()'; } else if (primaryKey.type === 'UUID') { @@ -80,7 +80,7 @@ _%> import <%= packageName %>.AbstractCassandraTest; <%_ } _%> import <%= packageName %>.IntegrationTest; -import <%= packageName %>.domain.<%= asEntity(entityClass) %>; +import <%= packageName %>.domain.<%= persistClass %>; <%_ var imported = []; for (relationship of relationships) { // import entities in required relationships @@ -109,7 +109,7 @@ import <%= packageName %>.repository.search.<%= entityClass %>SearchRepository; import <%= packageName %>.service.<%= entityClass %>Service; <%_ } _%> <%_ if (dto === 'mapstruct') { _%> -import <%= packageName %>.service.dto.<%= asDto(entityClass) %>; +import <%= packageName %>.service.dto.<%= dtoClass %>; import <%= packageName %>.service.mapper.<%= entityClass %>Mapper; <%_ } _%> <%_ if (jpaMetamodelFiltering) { _%> @@ -481,7 +481,7 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte private WebTestClient webTestClient; <%_ } _%> - private <%= asEntity(entityClass) %> <%= asEntity(entityInstance) %>; + private <%= persistClass %> <%= persistInstance %>; <%_ ['DEFAULT_', 'UPDATED_'].forEach((fieldStatus) => { _%> /** @@ -490,17 +490,17 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte * This is a static method, as tests for other entities might also need it, * if they test an entity which requires the current entity. */ - public static <%= asEntity(entityClass) %> create<% if (fieldStatus === 'UPDATED_') { _%>Updated<%_ } %>Entity(<% if (databaseType === 'sql') { %>EntityManager em<% } %>) { + public static <%= persistClass %> create<% if (fieldStatus === 'UPDATED_') { _%>Updated<%_ } %>Entity(<% if (databaseType === 'sql') { %>EntityManager em<% } %>) { <%_ if (fluentMethods) { _%> - <%= asEntity(entityClass) %> <%= asEntity(entityInstance) %> = new <%= asEntity(entityClass) %>()<% for (field of fields.filter(field => !field.id && !field.transient)) { %> + <%= persistClass %> <%= persistInstance %> = new <%= persistClass %>()<% for (field of fields.filter(field => !field.id && !field.transient)) { %> .<%= field.fieldName %>(<%= fieldStatus + field.fieldNameUnderscored.toUpperCase() %>)<% if ((field.fieldType === 'byte[]' || field.fieldType === 'ByteBuffer') && field.fieldTypeBlobContent !== 'text') { %> .<%= field.fieldName %>ContentType(<%= fieldStatus + field.fieldNameUnderscored.toUpperCase() %>_CONTENT_TYPE)<% } %><% } %>; <%_ } else { _%> - <%= asEntity(entityClass) %> <%= asEntity(entityInstance) %> = new <%= asEntity(entityClass) %>(); + <%= persistClass %> <%= persistInstance %> = new <%= persistClass %>(); <%_ for (field of fields.filter(field => !field.id && !field.transient)) { _%> - <%= asEntity(entityInstance) %>.set<%= field.fieldInJavaBeanMethod %>(<%= fieldStatus + field.fieldNameUnderscored.toUpperCase() %>); + <%= persistInstance %>.set<%= field.fieldInJavaBeanMethod %>(<%= fieldStatus + field.fieldNameUnderscored.toUpperCase() %>); <%_ if ((field.fieldType === 'byte[]' || field.fieldType === 'ByteBuffer') && field.fieldTypeBlobContent !== 'text') { _%> - <%= asEntity(entityInstance) %>.set<%= field.fieldInJavaBeanMethod %>ContentType(<%= fieldStatus + field.fieldNameUnderscored.toUpperCase() %>_CONTENT_TYPE); + <%= persistInstance %>.set<%= field.fieldInJavaBeanMethod %>ContentType(<%= fieldStatus + field.fieldNameUnderscored.toUpperCase() %>_CONTENT_TYPE); <%_ } _%> <%_ } _%> <%_ } _%> @@ -545,13 +545,13 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte <%_ } _%> <%_ } _%> <%_ if (relationshipType === 'many-to-many' || relationshipType === 'one-to-many') { _%> - <%= asEntity(entityInstance) %>.get<%= relationshipNameCapitalizedPlural %>().add(<%= otherEntityName %>); + <%= persistInstance %>.get<%= relationshipNameCapitalizedPlural %>().add(<%= otherEntityName %>); <%_ } else { _%> - <%= asEntity(entityInstance) %>.set<%= relationshipNameCapitalized %>(<%= otherEntityName %>); + <%= persistInstance %>.set<%= relationshipNameCapitalized %>(<%= otherEntityName %>); <%_ } _%> <%_ alreadyGeneratedEntities.push(otherEntityName) _%> <%_ } } _%> - return <%= asEntity(entityInstance) %>; + return <%= persistInstance %>; } <%_ }); _%> @@ -596,7 +596,7 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte <%_ } else if (databaseType === 'sql' && reactive) { _%> deleteEntities(em); <%_ } _%> - <%= asEntity(entityInstance) %> = createEntity(<% if (databaseType === 'sql') { %>em<% } %>); + <%= persistInstance %> = createEntity(<% if (databaseType === 'sql') { %>em<% } %>); } <%_ if (!readOnly) { _%> @@ -610,17 +610,17 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte <%_ } _%> // Create the <%= entityClass %> <%_ if (dto === 'mapstruct') { _%> - <%= asDto(entityClass) %> <%= asDto(entityInstance) %> = <%= entityInstance %>Mapper.toDto(<%= asEntity(entityInstance) %>); + <%= dtoClass %> <%= dtoInstance %> = <%= entityInstance %>Mapper.toDto(<%= persistInstance %>); <%_ } _%> <%_ if (!reactive) { _%> rest<%= entityClass %>MockMvc.perform(post(ENTITY_API_URL)<% if (testsNeedCsrf) { %>.with(csrf())<% }%> .contentType(MediaType.APPLICATION_JSON) - .content(TestUtil.convertObjectToJsonBytes(<%= (dto === 'mapstruct' ? asDto(entityInstance) : asEntity(entityInstance))%>))) + .content(TestUtil.convertObjectToJsonBytes(<%= restInstance %>))) .andExpect(status().isCreated()); <%_ } else { _%> webTestClient.post().uri(ENTITY_API_URL) .contentType(MediaType.APPLICATION_JSON) - .bodyValue(TestUtil.convertObjectToJsonBytes(<%= (dto === 'mapstruct' ? asDto(entityInstance) : asEntity(entityInstance))%>)) + .bodyValue(TestUtil.convertObjectToJsonBytes(<%= restInstance %>)) .exchange() .expectStatus().isCreated(); <%_ } _%> @@ -629,9 +629,9 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte <%_ if (databaseType === 'couchbase') { _%> SecurityContextHolder.setContext(TestSecurityContextHolder.getContext()); <%_ } _%> - List<<%= asEntity(entityClass) %>> <%= entityInstance %>List = <%= entityInstance %>Repository.findAll()<%= callListBlock %>; + List<<%= persistClass %>> <%= entityInstance %>List = <%= entityInstance %>Repository.findAll()<%= callListBlock %>; assertThat(<%= entityInstance %>List).hasSize(databaseSizeBeforeCreate + 1); - <%= asEntity(entityClass) %> test<%= entityClass %> = <%= entityInstance %>List.get(<%= entityInstance %>List.size() - 1); + <%= persistClass %> test<%= entityClass %> = <%= entityInstance %>List.get(<%= entityInstance %>List.size() - 1); <%_ for (const field of fields.filter(field => !field.id && !field.transient)) { if (field.fieldType === 'ZonedDateTime') { _%> assertThat(test<%= entityClass %>.get<%= field.fieldInJavaBeanMethod %>()).isEqualTo(<%= 'DEFAULT_' + field.fieldNameUnderscored.toUpperCase() %>); @@ -660,12 +660,12 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte void create<%= entityClass %>WithExistingId() throws Exception { // Create the <%= entityClass %> with an existing ID <%_ if (primaryKey.type === 'UUID' && databaseType === 'sql') { _%> - <%= entityInstance %>Repository.<%= saveMethod %>(<%= asEntity(entityInstance) %>)<%= callBlock %>; + <%= entityInstance %>Repository.<%= saveMethod %>(<%= persistInstance %>)<%= callBlock %>; <%_ } else { _%> - <%= asEntity(entityInstance) %>.set<%= primaryKey.nameCapitalized %>(<% if (primaryKey.type === 'UUID') { %>UUID.randomUUID()<% } else if (primaryKey.type === 'Long') { %>1L<% } else { %>"existing_id"<% } %>); + <%= persistInstance %>.set<%= primaryKey.nameCapitalized %>(<% if (primaryKey.type === 'UUID') { %>UUID.randomUUID()<% } else if (primaryKey.type === 'Long') { %>1L<% } else { %>"existing_id"<% } %>); <%_ } _%> <%_ if (dto === 'mapstruct') { _%> - <%= asDto(entityClass) %> <%= asDto(entityInstance) %> = <%= entityInstance %>Mapper.toDto(<%= asEntity(entityInstance) %>); + <%= dtoClass %> <%= dtoInstance %> = <%= entityInstance %>Mapper.toDto(<%= persistInstance %>); <%_ } _%> int databaseSizeBeforeCreate = <%= entityInstance %>Repository.findAll()<%= callListBlock %>.size(); @@ -674,12 +674,12 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte <%_ if (!reactive) { _%> rest<%= entityClass %>MockMvc.perform(post(ENTITY_API_URL)<% if (testsNeedCsrf) { %>.with(csrf())<% }%> .contentType(MediaType.APPLICATION_JSON) - .content(TestUtil.convertObjectToJsonBytes(<%= (dto === 'mapstruct' ? asDto(entityInstance) : asEntity(entityInstance)) %>))) + .content(TestUtil.convertObjectToJsonBytes(<%= restInstance %>))) .andExpect(status().isBadRequest()); <%_ } else { _%> webTestClient.post().uri(ENTITY_API_URL) .contentType(MediaType.APPLICATION_JSON) - .bodyValue(TestUtil.convertObjectToJsonBytes(<%= (dto === 'mapstruct' ? asDto(entityInstance) : asEntity(entityInstance))%>)) + .bodyValue(TestUtil.convertObjectToJsonBytes(<%= restInstance %>)) .exchange() .expectStatus().isBadRequest(); <%_ } _%> @@ -688,12 +688,12 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte <%_ if (databaseType === 'couchbase') { _%> SecurityContextHolder.setContext(TestSecurityContextHolder.getContext()); <%_ } _%> - List<<%= asEntity(entityClass) %>> <%= entityInstance %>List = <%= entityInstance %>Repository.findAll()<%= callListBlock %>; + List<<%= persistClass %>> <%= entityInstance %>List = <%= entityInstance %>Repository.findAll()<%= callListBlock %>; assertThat(<%= entityInstance %>List).hasSize(databaseSizeBeforeCreate); <%_ if (searchEngine === 'elasticsearch') { _%> // Validate the <%= entityClass %> in Elasticsearch - verify(mock<%= entityClass %>SearchRepository, times(0)).save(<%= asEntity(entityInstance) %>); + verify(mock<%= entityClass %>SearchRepository, times(0)).save(<%= persistInstance %>); <%_ } _%> } @@ -701,7 +701,7 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte @Test<%= transactionalAnnotation %> void update<%= entityClass %>MapsIdAssociationWithNewId() throws Exception { // Initialize the database - <%= entityInstance %>Repository.<%= saveMethod %>(<%= asEntity(entityInstance) %>)<%= callBlock %>; + <%= entityInstance %>Repository.<%= saveMethod %>(<%= persistInstance %>)<%= callBlock %>; <%_ const alreadyGeneratedEntities = []; _%> int databaseSizeBeforeCreate = <%= entityInstance %>Repository.findAll()<%= callListBlock %>.size(); @@ -723,29 +723,29 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte <%_ } break; } _%> // Load the <%= entityInstance %> - <%= asEntity(entityClass) %> updated<%= asEntity(entityClass) %> = <%= entityInstance %>Repository.findById(<%= asEntity(entityInstance) %>.get<%= primaryKey.nameCapitalized %>())<%= reactive ? '.block()' : '.get()' %>; - assertThat(updated<%= asEntity(entityClass) %>).isNotNull();<% if (databaseType === 'sql' && !reactive) { %> - // Disconnect from session so that the updates on updated<%= asEntity(entityClass) %> are not directly saved in db - em.detach(updated<%= asEntity(entityClass) %>);<% } %> + <%= persistClass %> updated<%= persistClass %> = <%= entityInstance %>Repository.findById(<%= persistInstance %>.get<%= primaryKey.nameCapitalized %>())<%= reactive ? '.block()' : '.get()' %>; + assertThat(updated<%= persistClass %>).isNotNull();<% if (databaseType === 'sql' && !reactive) { %> + // Disconnect from session so that the updates on updated<%= persistClass %> are not directly saved in db + em.detach(updated<%= persistClass %>);<% } %> // Update the <%= mapsIdEntity %> with new association value - updated<%= asEntity(entityClass) %>.set<%= mapsIdEntity %>(<%= alreadyGeneratedEntities.pop() %>); + updated<%= persistClass %>.set<%= mapsIdEntity %>(<%= alreadyGeneratedEntities.pop() %>); <%_ if (dto === 'mapstruct') { _%> - <%= asDto(entityClass) %> updated<%= asDto(entityClass) %> = <%= entityInstance %>Mapper.toDto(updated<%= asEntity(entityClass) %>); - assertThat(updated<%= asDto(entityClass) %>).isNotNull(); + <%= dtoClass %> updated<%= dtoClass %> = <%= entityInstance %>Mapper.toDto(updated<%= persistClass %>); + assertThat(updated<%= dtoClass %>).isNotNull(); <%_ } _%> // Update the entity <%_ if (reactive) { _%> - webTestClient.put().uri(ENTITY_API_URL_ID, <%_ if (dto === 'mapstruct') { _%>updated<%= asDto(entityClass) %> <%_ } else { _%> updated<%= asEntity(entityClass) %> <%_ } _%>.get<%= primaryKey.nameCapitalized %>()) + webTestClient.put().uri(ENTITY_API_URL_ID, <%_ if (dto === 'mapstruct') { _%>updated<%= dtoClass %> <%_ } else { _%> updated<%= persistClass %> <%_ } _%>.get<%= primaryKey.nameCapitalized %>()) .contentType(MediaType.APPLICATION_JSON) - .bodyValue(TestUtil.convertObjectToJsonBytes(<%_ if (dto === 'mapstruct') { _%>updated<%= asDto(entityClass) %> <%_ } else { _%> updated<%= asEntity(entityClass) %> <%_ } _%>)) + .bodyValue(TestUtil.convertObjectToJsonBytes(<%_ if (dto === 'mapstruct') { _%>updated<%= dtoClass %> <%_ } else { _%> updated<%= persistClass %> <%_ } _%>)) .exchange() .expectStatus().isOk(); <%_ } else { _%> - rest<%= entityClass %>MockMvc.perform(put(ENTITY_API_URL_ID, <%_ if (dto === 'mapstruct') { _%>updated<%= asDto(entityClass) %> <%_ } else { _%> updated<%= asEntity(entityClass) %> <%_ } _%>.get<%= primaryKey.nameCapitalized %>())<% if (testsNeedCsrf) { %>.with(csrf())<% }%> + rest<%= entityClass %>MockMvc.perform(put(ENTITY_API_URL_ID, <%_ if (dto === 'mapstruct') { _%>updated<%= dtoClass %> <%_ } else { _%> updated<%= persistClass %> <%_ } _%>.get<%= primaryKey.nameCapitalized %>())<% if (testsNeedCsrf) { %>.with(csrf())<% }%> .contentType(MediaType.APPLICATION_JSON) - .content(TestUtil.convertObjectToJsonBytes(<%_ if (dto === 'mapstruct') { _%>updated<%= asDto(entityClass) %> <%_ } else { _%> updated<%= asEntity(entityClass) %> <%_ } _%>))) + .content(TestUtil.convertObjectToJsonBytes(<%_ if (dto === 'mapstruct') { _%>updated<%= dtoClass %> <%_ } else { _%> updated<%= persistClass %> <%_ } _%>))) .andExpect(status().isOk()); <%_ } _%> @@ -753,9 +753,9 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte <%_ if (databaseType === 'couchbase') { _%> SecurityContextHolder.setContext(TestSecurityContextHolder.getContext()); <%_ } _%> - List<<%= asEntity(entityClass) %>> <%= entityInstance %>List = <%= entityInstance %>Repository.findAll()<%= callListBlock %>; + List<<%= persistClass %>> <%= entityInstance %>List = <%= entityInstance %>Repository.findAll()<%= callListBlock %>; assertThat(<%= entityInstance %>List).hasSize(databaseSizeBeforeCreate); - <%= asEntity(entityClass) %> test<%= entityClass %> = <%= entityInstance %>List.get(<%= entityInstance %>List.size() - 1); + <%= persistClass %> test<%= entityClass %> = <%= entityInstance %>List.get(<%= entityInstance %>List.size() - 1); // Validate the id for MapsId, the ids must be same // Uncomment the following line for assertion. However, please note that there is a known issue and uncommenting will fail the test. @@ -764,7 +764,7 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte <%_ if (searchEngine === 'elasticsearch') { _%> // Validate the <%= entityClass %> in Elasticsearch - verify(mock<%= entityClass %>SearchRepository).save(<%= asEntity(entityInstance) %>); + verify(mock<%= entityClass %>SearchRepository).save(<%= persistInstance %>); <%_ } _%> } <%_ } _%> @@ -778,21 +778,21 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte void check<%= field.fieldInJavaBeanMethod %>IsRequired() throws Exception { int databaseSizeBeforeTest = <%= entityInstance %>Repository.findAll()<%= callListBlock %>.size(); // set the field null - <%= asEntity(entityInstance) %>.set<%= field.fieldInJavaBeanMethod %>(null); + <%= persistInstance %>.set<%= field.fieldInJavaBeanMethod %>(null); // Create the <%= entityClass %>, which fails.<% if (dto === 'mapstruct') { %> - <%= asDto(entityClass) %> <%= asDto(entityInstance) %> = <%= entityInstance %>Mapper.toDto(<%= asEntity(entityInstance) %>);<% } %> + <%= dtoClass %> <%= dtoInstance %> = <%= entityInstance %>Mapper.toDto(<%= persistInstance %>);<% } %> <%_ if (!reactive) { _%> rest<%= entityClass %>MockMvc.perform(post(ENTITY_API_URL)<% if (testsNeedCsrf) { %>.with(csrf())<% }%> .contentType(MediaType.APPLICATION_JSON) - .content(TestUtil.convertObjectToJsonBytes(<%= (dto === 'mapstruct' ? asDto(entityInstance) : asEntity(entityInstance)) %>))) + .content(TestUtil.convertObjectToJsonBytes(<%= restInstance %>))) .andExpect(status().isBadRequest()); <%_ } else { _%> webTestClient.post().uri(ENTITY_API_URL) .contentType(MediaType.APPLICATION_JSON) - .bodyValue(TestUtil.convertObjectToJsonBytes(<%= (dto === 'mapstruct' ? asDto(entityInstance) : asEntity(entityInstance))%>)) + .bodyValue(TestUtil.convertObjectToJsonBytes(<%= restInstance %>)) .exchange() .expectStatus().isBadRequest(); <%_ } _%> @@ -800,7 +800,7 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte <%_ if (databaseType === 'couchbase') { _%> SecurityContextHolder.setContext(TestSecurityContextHolder.getContext()); <%_ } _%> - List<<%= asEntity(entityClass) %>> <%= entityInstance %>List = <%= entityInstance %>Repository.findAll()<%= callListBlock %>; + List<<%= persistClass %>> <%= entityInstance %>List = <%= entityInstance %>Repository.findAll()<%= callListBlock %>; assertThat(<%= entityInstance %>List).hasSize(databaseSizeBeforeTest); } <%_ } } } _%> @@ -811,27 +811,27 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte void getAll<%= entityClassPlural %>AsStream() { // Initialize the database <%_ if (primaryKey.type === 'UUID' && databaseType !== 'sql') { _%> - <%= asEntity(entityInstance) %>.set<%= primaryKey.nameCapitalized %>(UUID.randomUUID()); + <%= persistInstance %>.set<%= primaryKey.nameCapitalized %>(UUID.randomUUID()); <%_ } _%> - <%= entityInstance %>Repository.save(<%= asEntity(entityInstance) %>)<%= callBlock %>; + <%= entityInstance %>Repository.save(<%= persistInstance %>)<%= callBlock %>; List<<%= entityClass %>> <%= entityInstance %>List = webTestClient.get().uri(ENTITY_API_URL) .accept(MediaType.APPLICATION_NDJSON) .exchange() .expectStatus().isOk() .expectHeader().contentTypeCompatibleWith(MediaType.APPLICATION_NDJSON) - .returnResult(<%= dto !== 'no' ? asDto(entityClass) : asEntity(entityClass) %>.class) + .returnResult(<%= restClass %>.class) .getResponseBody() <%_ if (dto !== 'no') { _%> .map(<%= entityInstance %>Mapper::toEntity) <%_ } _%> - .filter(<%= asEntity(entityInstance) %>::equals) + .filter(<%= persistInstance %>::equals) .collectList() .block(Duration.ofSeconds(5)); assertThat(<%= entityInstance %>List).isNotNull(); assertThat(<%= entityInstance %>List).hasSize(1); - <%= asEntity(entityClass) %> test<%= entityClass %> = <%= entityInstance %>List.get(0); + <%= persistClass %> test<%= entityClass %> = <%= entityInstance %>List.get(0); <%_ for (const field of fields.filter(field => !field.id && !field.transient)) { if (field.fieldType === 'ZonedDateTime') { _%> assertThat(test<%= entityClass %>.get<%= field.fieldInJavaBeanMethod %>()).isEqualTo(<%= 'DEFAULT_' + field.fieldNameUnderscored.toUpperCase() %>); @@ -851,9 +851,9 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte void getAll<%= entityClassPlural %>() <% if (!reactive) { %>throws Exception <% } %>{ // Initialize the database <%_ if (primaryKey.type === 'UUID' && databaseType !== 'sql') { _%> - <%= asEntity(entityInstance) %>.set<%= primaryKey.nameCapitalized %>(UUID.randomUUID()); + <%= persistInstance %>.set<%= primaryKey.nameCapitalized %>(UUID.randomUUID()); <%_ } _%> - <%= entityInstance %>Repository.<%= saveMethod %>(<%= asEntity(entityInstance) %>)<%= callBlock %>; + <%= entityInstance %>Repository.<%= saveMethod %>(<%= persistInstance %>)<%= callBlock %>; // Get all the <%= entityInstance %>List <%_ if (!reactive) { _%> @@ -942,17 +942,17 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte void get<%= entityClass %>() <% if (!reactive) { %>throws Exception <% } %>{ // Initialize the database <%_ if (primaryKey.type === 'UUID' && databaseType !== 'sql') { _%> - <%= asEntity(entityInstance) %>.set<%= primaryKey.nameCapitalized %>(UUID.randomUUID()); + <%= persistInstance %>.set<%= primaryKey.nameCapitalized %>(UUID.randomUUID()); <%_ } _%> - <%= entityInstance %>Repository.<%= saveMethod %>(<%= asEntity(entityInstance) %>)<%= callBlock %>; + <%= entityInstance %>Repository.<%= saveMethod %>(<%= persistInstance %>)<%= callBlock %>; // Get the <%= entityInstance %> <%_ if (!reactive) { _%> - rest<%= entityClass %>MockMvc.perform(get(ENTITY_API_URL_ID, <%= asEntity(entityInstance) %>.get<%= primaryKey.nameCapitalized %>())) + rest<%= entityClass %>MockMvc.perform(get(ENTITY_API_URL_ID, <%= persistInstance %>.get<%= primaryKey.nameCapitalized %>())) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) <%_ } else { _%> - webTestClient.get().uri(ENTITY_API_URL_ID, <%= asEntity(entityInstance) %>.get<%= primaryKey.nameCapitalized %>()) + webTestClient.get().uri(ENTITY_API_URL_ID, <%= persistInstance %>.get<%= primaryKey.nameCapitalized %>()) .accept(MediaType.APPLICATION_JSON) .exchange() .expectStatus().isOk() @@ -984,9 +984,9 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte @Test<%= transactionalAnnotation %> void get<%= entityClassPlural %>ByIdFiltering() <% if (!reactive) { %>throws Exception <% } %>{ // Initialize the database - <%= entityInstance %>Repository.<%= saveMethod %>(<%= asEntity(entityInstance) %>)<%= callBlock %>; + <%= entityInstance %>Repository.<%= saveMethod %>(<%= persistInstance %>)<%= callBlock %>; - <%= primaryKey.type %> id = <%= asEntity(entityInstance) %>.get<%= primaryKey.nameCapitalized %>(); + <%= primaryKey.type %> id = <%= persistInstance %>.get<%= primaryKey.nameCapitalized %>(); default<%= entityClass %>ShouldBeFound("<%= primaryKey.name %>.equals=" + id); default<%= entityClass %>ShouldNotBeFound("<%= primaryKey.name %>.notEquals=" + id); @@ -1009,7 +1009,7 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte @Test<%= transactionalAnnotation %> void getAll<%= entityClassPlural %>By<%= searchBy.fieldInJavaBeanMethod %>IsEqualToSomething() <% if (!reactive) { %>throws Exception <% } %>{ // Initialize the database - <%= entityInstance %>Repository.<%= saveMethod %>(<%= asEntity(entityInstance) %>)<%= callBlock %>; + <%= entityInstance %>Repository.<%= saveMethod %>(<%= persistInstance %>)<%= callBlock %>; // Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> equals to <%= 'DEFAULT_' + searchBy.fieldNameUnderscored.toUpperCase() %> default<%= entityClass %>ShouldBeFound("<%= searchBy.fieldName %>.equals=" + <%= 'DEFAULT_' + searchBy.fieldNameUnderscored.toUpperCase() %>); @@ -1021,7 +1021,7 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte @Test<%= transactionalAnnotation %> void getAll<%= entityClassPlural %>By<%= searchBy.fieldInJavaBeanMethod %>IsNotEqualToSomething() <% if (!reactive) { %>throws Exception <% } %>{ // Initialize the database - <%= entityInstance %>Repository.<%= saveMethod %>(<%= asEntity(entityInstance) %>)<%= callBlock %>; + <%= entityInstance %>Repository.<%= saveMethod %>(<%= persistInstance %>)<%= callBlock %>; // Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> not equals to <%= 'DEFAULT_' + searchBy.fieldNameUnderscored.toUpperCase() %> default<%= entityClass %>ShouldNotBeFound("<%= searchBy.fieldName %>.notEquals=" + <%= 'DEFAULT_' + searchBy.fieldNameUnderscored.toUpperCase() %>); @@ -1033,7 +1033,7 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte @Test<%= transactionalAnnotation %> void getAll<%= entityClassPlural %>By<%= searchBy.fieldInJavaBeanMethod %>IsInShouldWork() <% if (!reactive) { %>throws Exception <% } %>{ // Initialize the database - <%= entityInstance %>Repository.<%= saveMethod %>(<%= asEntity(entityInstance) %>)<%= callBlock %>; + <%= entityInstance %>Repository.<%= saveMethod %>(<%= persistInstance %>)<%= callBlock %>; // Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> in <%= 'DEFAULT_' + searchBy.fieldNameUnderscored.toUpperCase() %> or <%= 'UPDATED_' + searchBy.fieldNameUnderscored.toUpperCase() %> default<%= entityClass %>ShouldBeFound("<%= searchBy.fieldName %>.in=" + <%= 'DEFAULT_' + searchBy.fieldNameUnderscored.toUpperCase() %> + "," + <%= 'UPDATED_' + searchBy.fieldNameUnderscored.toUpperCase() %>); @@ -1045,7 +1045,7 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte @Test<%= transactionalAnnotation %> void getAll<%= entityClassPlural %>By<%= searchBy.fieldInJavaBeanMethod %>IsNullOrNotNull() <% if (!reactive) { %>throws Exception <% } %>{ // Initialize the database - <%= entityInstance %>Repository.<%= saveMethod %>(<%= asEntity(entityInstance) %>)<%= callBlock %>; + <%= entityInstance %>Repository.<%= saveMethod %>(<%= persistInstance %>)<%= callBlock %>; // Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> is not null default<%= entityClass %>ShouldBeFound("<%= searchBy.fieldName %>.specified=true"); @@ -1060,7 +1060,7 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte @Test<%= transactionalAnnotation %> void getAll<%= entityClassPlural %>By<%= searchBy.fieldInJavaBeanMethod %>ContainsSomething() <% if (!reactive) { %>throws Exception <% } %>{ // Initialize the database - <%= entityInstance %>Repository.<%= saveMethod %>(<%= asEntity(entityInstance) %>)<%= callBlock %>; + <%= entityInstance %>Repository.<%= saveMethod %>(<%= persistInstance %>)<%= callBlock %>; // Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> contains <%= 'DEFAULT_' + searchBy.fieldNameUnderscored.toUpperCase() %> default<%= entityClass %>ShouldBeFound("<%= searchBy.fieldName %>.contains=" + <%= 'DEFAULT_' + searchBy.fieldNameUnderscored.toUpperCase() %>); @@ -1072,7 +1072,7 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte @Test<%= transactionalAnnotation %> void getAll<%= entityClassPlural %>By<%= searchBy.fieldInJavaBeanMethod %>NotContainsSomething() <% if (!reactive) { %>throws Exception <% } %>{ // Initialize the database - <%= entityInstance %>Repository.<%= saveMethod %>(<%= asEntity(entityInstance) %>)<%= callBlock %>; + <%= entityInstance %>Repository.<%= saveMethod %>(<%= persistInstance %>)<%= callBlock %>; // Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> does not contain <%= 'DEFAULT_' + searchBy.fieldNameUnderscored.toUpperCase() %> default<%= entityClass %>ShouldNotBeFound("<%= searchBy.fieldName %>.doesNotContain=" + <%= 'DEFAULT_' + searchBy.fieldNameUnderscored.toUpperCase() %>); @@ -1104,7 +1104,7 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte @Test<%= transactionalAnnotation %> void getAll<%= entityClassPlural %>By<%= searchBy.fieldInJavaBeanMethod %>IsGreaterThanOrEqualToSomething() <% if (!reactive) { %>throws Exception <% } %>{ // Initialize the database - <%= entityInstance %>Repository.<%= saveMethod %>(<%= asEntity(entityInstance) %>)<%= callBlock %>; + <%= entityInstance %>Repository.<%= saveMethod %>(<%= persistInstance %>)<%= callBlock %>; // Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> is greater than or equal to <%= defaultValue %> default<%= entityClass %>ShouldBeFound("<%= searchBy.fieldName %>.greaterThanOrEqual=" + <%= defaultValue %>); @@ -1116,7 +1116,7 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte @Test<%= transactionalAnnotation %> void getAll<%= entityClassPlural %>By<%= searchBy.fieldInJavaBeanMethod %>IsLessThanOrEqualToSomething() <% if (!reactive) { %>throws Exception <% } %>{ // Initialize the database - <%= entityInstance %>Repository.<%= saveMethod %>(<%= asEntity(entityInstance) %>)<%= callBlock %>; + <%= entityInstance %>Repository.<%= saveMethod %>(<%= persistInstance %>)<%= callBlock %>; // Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> is less than or equal to <%= defaultValue %> default<%= entityClass %>ShouldBeFound("<%= searchBy.fieldName %>.lessThanOrEqual=" + <%= defaultValue %>); @@ -1128,7 +1128,7 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte @Test<%= transactionalAnnotation %> void getAll<%= entityClassPlural %>By<%= searchBy.fieldInJavaBeanMethod %>IsLessThanSomething() <% if (!reactive) { %>throws Exception <% } %>{ // Initialize the database - <%= entityInstance %>Repository.<%= saveMethod %>(<%= asEntity(entityInstance) %>)<%= callBlock %>; + <%= entityInstance %>Repository.<%= saveMethod %>(<%= persistInstance %>)<%= callBlock %>; // Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> is less than <%= defaultValue %> default<%= entityClass %>ShouldNotBeFound("<%= searchBy.fieldName %>.lessThan=" + <%= defaultValue %>); @@ -1140,7 +1140,7 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte @Test<%= transactionalAnnotation %> void getAll<%= entityClassPlural %>By<%= searchBy.fieldInJavaBeanMethod %>IsGreaterThanSomething() <% if (!reactive) { %>throws Exception <% } %>{ // Initialize the database - <%= entityInstance %>Repository.<%= saveMethod %>(<%= asEntity(entityInstance) %>)<%= callBlock %>; + <%= entityInstance %>Repository.<%= saveMethod %>(<%= persistInstance %>)<%= callBlock %>; // Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> is greater than <%= defaultValue %> default<%= entityClass %>ShouldNotBeFound("<%= searchBy.fieldName %>.greaterThan=" + <%= defaultValue %>); @@ -1157,23 +1157,23 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte void getAll<%= entityClassPlural %>By<%= relationship.relationshipNameCapitalized %>IsEqualToSomething() <% if (!reactive) { %>throws Exception <% } %>{ <%_ if ((relationship.relationshipValidate === true && relationship.relationshipType === 'one-to-one') || relationship.id === true) { _%> // Get already existing entity - <%= asEntity(relationship.otherEntityNameCapitalized) %> <%= relationship.relationshipFieldName %> = <%= asEntity(entityInstance) %>.get<%= relationship.relationshipNameCapitalized %>(); + <%= asEntity(relationship.otherEntityNameCapitalized) %> <%= relationship.relationshipFieldName %> = <%= persistInstance %>.get<%= relationship.relationshipNameCapitalized %>(); <%_ } else { _%> // Initialize the database - <%= entityInstance %>Repository.saveAndFlush(<%= asEntity(entityInstance) %>); + <%= entityInstance %>Repository.saveAndFlush(<%= persistInstance %>); <%= asEntity(relationship.otherEntityNameCapitalized) %> <%= relationship.relationshipFieldName %> = <%= relationship.otherEntityNameCapitalized %>ResourceIT.createEntity(em); em.persist(<%= relationship.relationshipFieldName %>); em.flush(); <%_ if (relationship.relationshipType === 'many-to-many' || relationship.relationshipType === 'one-to-many') { _%> - <%= asEntity(entityInstance) %>.add<%= relationship.relationshipNameCapitalized %>(<%= relationship.relationshipFieldName %>); + <%= persistInstance %>.add<%= relationship.relationshipNameCapitalized %>(<%= relationship.relationshipFieldName %>); <%_ } else { _%> - <%= asEntity(entityInstance) %>.set<%= relationship.relationshipNameCapitalized %>(<%= relationship.relationshipFieldName %>); + <%= persistInstance %>.set<%= relationship.relationshipNameCapitalized %>(<%= relationship.relationshipFieldName %>); <%_ if (relationship.ownerSide === false) { _%> - <%= relationship.relationshipFieldName %>.set<%= relationship.otherEntityRelationshipNameCapitalized %>(<%= asEntity(entityInstance) %>); + <%= relationship.relationshipFieldName %>.set<%= relationship.otherEntityRelationshipNameCapitalized %>(<%= persistInstance %>); <%_ } _%> <%_ } _%> <%_ } _%> - <%= entityInstance %>Repository.saveAndFlush(<%= asEntity(entityInstance) %>); + <%= entityInstance %>Repository.saveAndFlush(<%= persistInstance %>); <%= relationship.otherEntity.primaryKey.type %> <%= relationship.relationshipFieldName %>Id = <%= relationship.relationshipFieldName %>.get<%= relationship.otherEntity.primaryKey.nameCapitalized %>(); // Get all the <%= entityInstance %>List where <%= relationship.relationshipFieldName %> equals to <%= relationship.relationshipFieldName %>Id @@ -1238,7 +1238,7 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte 'UUID' : '.toString()' }[primaryKey.type] || ''; _%> - .andExpect(jsonPath("$.[*].<%= primaryKey.name %>").value(hasItem(<%= asEntity(entityInstance) %>.get<%= primaryKey.nameCapitalized %>()<%= primaryKeyConversion %>)))<% fields.filter(field => !field.id && !field.transient).forEach((field) => { %> + .andExpect(jsonPath("$.[*].<%= primaryKey.name %>").value(hasItem(<%= persistInstance %>.get<%= primaryKey.nameCapitalized %>()<%= primaryKeyConversion %>)))<% fields.filter(field => !field.id && !field.transient).forEach((field) => { %> <%_ if ((field.fieldType === 'byte[]' || field.fieldType === 'ByteBuffer') && field.fieldTypeBlobContent !== 'text') { _%> .andExpect(jsonPath("$.[*].<%= field.fieldName %>ContentType").value(hasItem(<%= 'DEFAULT_' + field.fieldNameUnderscored.toUpperCase() %>_CONTENT_TYPE))) <%_ } _%> @@ -1327,43 +1327,43 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte <%_ } _%> // Initialize the database <%_ if (primaryKey.type === 'UUID' && databaseType !== 'sql') { _%> - <%= asEntity(entityInstance) %>.set<%= primaryKey.nameCapitalized %>(UUID.randomUUID()); + <%= persistInstance %>.set<%= primaryKey.nameCapitalized %>(UUID.randomUUID()); <%_ } _%> - <%= entityInstance %>Repository.<%= saveMethod %>(<%= asEntity(entityInstance) %>)<%= callBlock %>; + <%= entityInstance %>Repository.<%= saveMethod %>(<%= persistInstance %>)<%= callBlock %>; int databaseSizeBeforeUpdate = <%= entityInstance %>Repository.findAll()<%= callListBlock %>.size(); // Update the <%= entityInstance %> - <%= asEntity(entityClass) %> updated<%= asEntity(entityClass) %> = <%= entityInstance %>Repository.findById(<%= asEntity(entityInstance) %>.get<%= primaryKey.nameCapitalized %>())<%= reactive ? '.block()' : '.get()' %>; + <%= persistClass %> updated<%= persistClass %> = <%= entityInstance %>Repository.findById(<%= persistInstance %>.get<%= primaryKey.nameCapitalized %>())<%= reactive ? '.block()' : '.get()' %>; <%_ if (databaseType === 'sql' && !reactive) { _%> - // Disconnect from session so that the updates on updated<%= asEntity(entityClass) %> are not directly saved in db - em.detach(updated<%= asEntity(entityClass) %>); + // Disconnect from session so that the updates on updated<%= persistClass %> are not directly saved in db + em.detach(updated<%= persistClass %>); <%_ } _%> <%_ if (fluentMethods && fields.filter(field => !field.id && !field.transient).length > 0) { _%> - updated<%= asEntity(entityClass) %><% for (field of fields.filter(field => !field.id && !field.transient)) { %> + updated<%= persistClass %><% for (field of fields.filter(field => !field.id && !field.transient)) { %> .<%= field.fieldName %>(<%= 'UPDATED_' + field.fieldNameUnderscored.toUpperCase() %>)<% if ((field.fieldType === 'byte[]' || field.fieldType === 'ByteBuffer') && field.fieldTypeBlobContent !== 'text') { %> .<%= field.fieldName %>ContentType(<%= 'UPDATED_' + field.fieldNameUnderscored.toUpperCase() %>_CONTENT_TYPE)<% } %><% } %>; <%_ } else { _%> <%_ for (field of fields.filter(field => !field.id && !field.transient)) { _%> - updated<%= asEntity(entityClass) %>.set<%= field.fieldInJavaBeanMethod %>(<%= 'UPDATED_' + field.fieldNameUnderscored.toUpperCase() %>); + updated<%= persistClass %>.set<%= field.fieldInJavaBeanMethod %>(<%= 'UPDATED_' + field.fieldNameUnderscored.toUpperCase() %>); <%_ if ((field.fieldType === 'byte[]' || field.fieldType === 'ByteBuffer') && field.fieldTypeBlobContent !== 'text') { _%> - updated<%= asEntity(entityClass) %>.set<%= field.fieldInJavaBeanMethod %>ContentType(<%= 'UPDATED_' + field.fieldNameUnderscored.toUpperCase() %>_CONTENT_TYPE); + updated<%= persistClass %>.set<%= field.fieldInJavaBeanMethod %>ContentType(<%= 'UPDATED_' + field.fieldNameUnderscored.toUpperCase() %>_CONTENT_TYPE); <%_ } _%> <%_ } _%> <%_ } _%> <%_ if (dto === 'mapstruct') { _%> - <%= asDto(entityClass) %> <%= asDto(entityInstance) %> = <%= entityInstance %>Mapper.toDto(updated<%= asEntity(entityClass) %>); + <%= dtoClass %> <%= dtoInstance %> = <%= entityInstance %>Mapper.toDto(updated<%= persistClass %>); <%_ } _%> <%_ if (!reactive) { _%> - rest<%= entityClass %>MockMvc.perform(put(ENTITY_API_URL_ID, <%= (dto === 'mapstruct' ? asDto(entityInstance) : 'updated' + asEntity(entityClass)) %>.get<%= primaryKey.nameCapitalized %>())<% if (testsNeedCsrf) { %>.with(csrf())<% }%> + rest<%= entityClass %>MockMvc.perform(put(ENTITY_API_URL_ID, <%= (dto === 'mapstruct' ? asDto(entityInstance) : 'updated' + persistClass) %>.get<%= primaryKey.nameCapitalized %>())<% if (testsNeedCsrf) { %>.with(csrf())<% }%> .contentType(MediaType.APPLICATION_JSON) - .content(TestUtil.convertObjectToJsonBytes(<%= (dto === 'mapstruct' ? asDto(entityInstance) : 'updated' + asEntity(entityClass)) %>))) + .content(TestUtil.convertObjectToJsonBytes(<%= (dto === 'mapstruct' ? asDto(entityInstance) : 'updated' + persistClass) %>))) .andExpect(status().isOk()); <%_ } else { _%> - webTestClient.put().uri(ENTITY_API_URL_ID, <%= (dto === 'mapstruct' ? asDto(entityInstance) : 'updated' + asEntity(entityClass)) %>.get<%= primaryKey.nameCapitalized %>()) + webTestClient.put().uri(ENTITY_API_URL_ID, <%= (dto === 'mapstruct' ? asDto(entityInstance) : 'updated' + persistClass) %>.get<%= primaryKey.nameCapitalized %>()) .contentType(MediaType.APPLICATION_JSON) - .bodyValue(TestUtil.convertObjectToJsonBytes(<%= (dto === 'mapstruct' ? asDto(entityInstance) : 'updated' + asEntity(entityClass)) %>)) + .bodyValue(TestUtil.convertObjectToJsonBytes(<%= (dto === 'mapstruct' ? asDto(entityInstance) : 'updated' + persistClass) %>)) .exchange() .expectStatus().isOk(); <%_ } _%> @@ -1372,9 +1372,9 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte <%_ if (databaseType === 'couchbase') { _%> SecurityContextHolder.setContext(TestSecurityContextHolder.getContext()); <%_ } _%> - List<<%= asEntity(entityClass) %>> <%= entityInstance %>List = <%= entityInstance %>Repository.findAll()<%= callListBlock %>; + List<<%= persistClass %>> <%= entityInstance %>List = <%= entityInstance %>Repository.findAll()<%= callListBlock %>; assertThat(<%= entityInstance %>List).hasSize(databaseSizeBeforeUpdate); - <%= asEntity(entityClass) %> test<%= entityClass %> = <%= entityInstance %>List.get(<%= entityInstance %>List.size() - 1); + <%= persistClass %> test<%= entityClass %> = <%= entityInstance %>List.get(<%= entityInstance %>List.size() - 1); <%_ for (const field of fields.filter(field => !field.id && !field.transient)) { if (field.fieldType === 'ZonedDateTime') { _%> assertThat(test<%= entityClass %>.get<%= field.fieldInJavaBeanMethod %>()).isEqualTo(<%= 'UPDATED_' + field.fieldNameUnderscored.toUpperCase() %>); @@ -1395,23 +1395,23 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte @Test<%= transactionalAnnotation %> void putNonExisting<%= entityClass %>() throws Exception { int databaseSizeBeforeUpdate = <%= entityInstance %>Repository.findAll()<%= callListBlock %>.size(); - <%= asEntity(entityInstance) %>.set<%= primaryKey.nameCapitalized %>(<%= getJavaValueGeneratorForType(primaryKey.type) %>); + <%= persistInstance %>.set<%= primaryKey.nameCapitalized %>(<%= getJavaValueGeneratorForType(primaryKey.type) %>); <%_ if (dto === 'mapstruct') { _%> // Create the <%= entityClass %> - <%= asDto(entityClass) %> <%= asDto(entityInstance) %> = <%= entityInstance %>Mapper.toDto(<%= asEntity(entityInstance) %>); + <%= dtoClass %> <%= dtoInstance %> = <%= entityInstance %>Mapper.toDto(<%= persistInstance %>); <%_ } _%> // If the entity doesn't have an ID, it will throw BadRequestAlertException <%_ if (!reactive) { _%> - rest<%= entityClass %>MockMvc.perform(put(ENTITY_API_URL_ID, <%= (dto === 'mapstruct' ? asDto(entityInstance) : asEntity(entityInstance)) %>.get<%= primaryKey.nameCapitalized %>())<% if (testsNeedCsrf) { %>.with(csrf())<% }%> + rest<%= entityClass %>MockMvc.perform(put(ENTITY_API_URL_ID, <%= restInstance %>.get<%= primaryKey.nameCapitalized %>())<% if (testsNeedCsrf) { %>.with(csrf())<% }%> .contentType(MediaType.APPLICATION_JSON) - .content(TestUtil.convertObjectToJsonBytes(<%= (dto === 'mapstruct' ? asDto(entityInstance) : asEntity(entityInstance)) %>))) + .content(TestUtil.convertObjectToJsonBytes(<%= restInstance %>))) .andExpect(status().isBadRequest()); <%_ } else { _%> - webTestClient.put().uri(ENTITY_API_URL_ID, <%= (dto === 'mapstruct' ? asDto(entityInstance) : asEntity(entityInstance)) %>.get<%= primaryKey.nameCapitalized %>()) + webTestClient.put().uri(ENTITY_API_URL_ID, <%= restInstance %>.get<%= primaryKey.nameCapitalized %>()) .contentType(MediaType.APPLICATION_JSON) - .bodyValue(TestUtil.convertObjectToJsonBytes(<%= (dto === 'mapstruct' ? asDto(entityInstance) : asEntity(entityInstance)) %>)) + .bodyValue(TestUtil.convertObjectToJsonBytes(<%= restInstance %>)) .exchange() .expectStatus().isBadRequest(); <%_ } _%> @@ -1420,35 +1420,35 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte <%_ if (databaseType === 'couchbase') { _%> SecurityContextHolder.setContext(TestSecurityContextHolder.getContext()); <%_ } _%> - List<<%= asEntity(entityClass) %>> <%= entityInstance %>List = <%= entityInstance %>Repository.findAll()<%= callListBlock %>; + List<<%= persistClass %>> <%= entityInstance %>List = <%= entityInstance %>Repository.findAll()<%= callListBlock %>; assertThat(<%= entityInstance %>List).hasSize(databaseSizeBeforeUpdate); <%_ if (searchEngine === 'elasticsearch') { _%> // Validate the <%= entityClass %> in Elasticsearch - verify(mock<%= entityClass %>SearchRepository, times(0)).save(<%= asEntity(entityInstance) %>); + verify(mock<%= entityClass %>SearchRepository, times(0)).save(<%= persistInstance %>); <%_ } _%> } @Test<%= transactionalAnnotation %> void putWithIdMismatch<%= entityClass %>() throws Exception { int databaseSizeBeforeUpdate = <%= entityInstance %>Repository.findAll()<%= callListBlock %>.size(); - <%= asEntity(entityInstance) %>.set<%= primaryKey.nameCapitalized %>(<%= getJavaValueGeneratorForType(primaryKey.type) %>); + <%= persistInstance %>.set<%= primaryKey.nameCapitalized %>(<%= getJavaValueGeneratorForType(primaryKey.type) %>); <%_ if (dto === 'mapstruct') { _%> // Create the <%= entityClass %> - <%= asDto(entityClass) %> <%= asDto(entityInstance) %> = <%= entityInstance %>Mapper.toDto(<%= asEntity(entityInstance) %>); + <%= dtoClass %> <%= dtoInstance %> = <%= entityInstance %>Mapper.toDto(<%= persistInstance %>); <%_ } _%> // If url ID doesn't match entity ID, it will throw BadRequestAlertException <%_ if (!reactive) { _%> rest<%= entityClass %>MockMvc.perform(put(ENTITY_API_URL_ID, <%= getJavaValueGeneratorForType(primaryKey.type) %>)<% if (testsNeedCsrf) { %>.with(csrf())<% } %> .contentType(MediaType.APPLICATION_JSON) - .content(TestUtil.convertObjectToJsonBytes(<%= (dto === 'mapstruct' ? asDto(entityInstance) : asEntity(entityInstance)) %>))) + .content(TestUtil.convertObjectToJsonBytes(<%= restInstance %>))) .andExpect(status().isBadRequest()); <%_ } else { _%> webTestClient.put().uri(ENTITY_API_URL_ID, <%= getJavaValueGeneratorForType(primaryKey.type) %>) .contentType(MediaType.APPLICATION_JSON) - .bodyValue(TestUtil.convertObjectToJsonBytes(<%= (dto === 'mapstruct' ? asDto(entityInstance) : asEntity(entityInstance)) %>)) + .bodyValue(TestUtil.convertObjectToJsonBytes(<%= restInstance %>)) .exchange() .expectStatus().isBadRequest(); <%_ } _%> @@ -1457,35 +1457,35 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte <%_ if (databaseType === 'couchbase') { _%> SecurityContextHolder.setContext(TestSecurityContextHolder.getContext()); <%_ } _%> - List<<%= asEntity(entityClass) %>> <%= entityInstance %>List = <%= entityInstance %>Repository.findAll()<%= callListBlock %>; + List<<%= persistClass %>> <%= entityInstance %>List = <%= entityInstance %>Repository.findAll()<%= callListBlock %>; assertThat(<%= entityInstance %>List).hasSize(databaseSizeBeforeUpdate); <%_ if (searchEngine === 'elasticsearch') { _%> // Validate the <%= entityClass %> in Elasticsearch - verify(mock<%= entityClass %>SearchRepository, times(0)).save(<%= asEntity(entityInstance) %>); + verify(mock<%= entityClass %>SearchRepository, times(0)).save(<%= persistInstance %>); <%_ } _%> } @Test<%= transactionalAnnotation %> void putWithMissingIdPathParam<%= entityClass %>() throws Exception { int databaseSizeBeforeUpdate = <%= entityInstance %>Repository.findAll()<%= callListBlock %>.size(); - <%= asEntity(entityInstance) %>.set<%= primaryKey.nameCapitalized %>(<%= getJavaValueGeneratorForType(primaryKey.type) %>); + <%= persistInstance %>.set<%= primaryKey.nameCapitalized %>(<%= getJavaValueGeneratorForType(primaryKey.type) %>); <%_ if (dto === 'mapstruct') { _%> // Create the <%= entityClass %> - <%= asDto(entityClass) %> <%= asDto(entityInstance) %> = <%= entityInstance %>Mapper.toDto(<%= asEntity(entityInstance) %>); + <%= dtoClass %> <%= dtoInstance %> = <%= entityInstance %>Mapper.toDto(<%= persistInstance %>); <%_ } _%> // If url ID doesn't match entity ID, it will throw BadRequestAlertException <%_ if (!reactive) { _%> rest<%= entityClass %>MockMvc.perform(put(ENTITY_API_URL)<% if (testsNeedCsrf) { %>.with(csrf())<% } %> .contentType(MediaType.APPLICATION_JSON) - .content(TestUtil.convertObjectToJsonBytes(<%= (dto === 'mapstruct' ? asDto(entityInstance) : asEntity(entityInstance)) %>))) + .content(TestUtil.convertObjectToJsonBytes(<%= restInstance %>))) .andExpect(status().isMethodNotAllowed()); <%_ } else { _%> webTestClient.put().uri(ENTITY_API_URL) .contentType(MediaType.APPLICATION_JSON) - .bodyValue(TestUtil.convertObjectToJsonBytes(<%= (dto === 'mapstruct' ? asDto(entityInstance) : asEntity(entityInstance)) %>)) + .bodyValue(TestUtil.convertObjectToJsonBytes(<%= restInstance %>)) .exchange() .expectStatus().isEqualTo(405); <%_ } _%> @@ -1494,12 +1494,12 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte <%_ if (databaseType === 'couchbase') { _%> SecurityContextHolder.setContext(TestSecurityContextHolder.getContext()); <%_ } _%> - List<<%= asEntity(entityClass) %>> <%= entityInstance %>List = <%= entityInstance %>Repository.findAll()<%= callListBlock %>; + List<<%= persistClass %>> <%= entityInstance %>List = <%= entityInstance %>Repository.findAll()<%= callListBlock %>; assertThat(<%= entityInstance %>List).hasSize(databaseSizeBeforeUpdate); <%_ if (searchEngine === 'elasticsearch') { _%> // Validate the <%= entityClass %> in Elasticsearch - verify(mock<%= entityClass %>SearchRepository, times(0)).save(<%= asEntity(entityInstance) %>); + verify(mock<%= entityClass %>SearchRepository, times(0)).save(<%= persistInstance %>); <%_ } _%> } @@ -1527,19 +1527,19 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte @Test<%= transactionalAnnotation %> void partialUpdate<%= entityClass %>ShouldThrown() throws Exception { // Update the <%= entityInstance %> without id should throw - <%= asEntity(entityClass) %> partialUpdated<%= asEntity(entityClass) %> = new <%= asEntity(entityClass) %>(); + <%= persistClass %> partialUpdated<%= persistClass %> = new <%= persistClass %>(); <%_ if (!reactive) { _%> rest<%= entityClass %>MockMvc.perform(patch(ENTITY_API_URL)<% if (testsNeedCsrf) { %>.with(csrf())<% }%> .contentType("application/merge-patch+json") - .content(TestUtil.convertObjectToJsonBytes(<%= 'partialUpdated' + asEntity(entityClass) %>))) + .content(TestUtil.convertObjectToJsonBytes(<%= 'partialUpdated' + persistClass %>))) .andExpect(status().isBadRequest()); <%_ } else { _%> webTestClient .patch() .uri(ENTITY_API_URL) .contentType(MediaType.valueOf("application/merge-patch+json")) - .bodyValue(TestUtil.convertObjectToJsonBytes(<%= 'partialUpdated' + asEntity(entityClass) %>)) + .bodyValue(TestUtil.convertObjectToJsonBytes(<%= 'partialUpdated' + persistClass %>)) .exchange() .expectStatus() .isBadRequest(); @@ -1558,19 +1558,19 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte <%_ } _%> // Initialize the database <%_ if (primaryKey.type === 'UUID' && databaseType !== 'sql') { _%> - <%= asEntity(entityInstance) %>.set<%= primaryKey.nameCapitalized %>(UUID.randomUUID()); + <%= persistInstance %>.set<%= primaryKey.nameCapitalized %>(UUID.randomUUID()); <%_ } _%> - <%= entityInstance %>Repository.<%= saveMethod %>(<%= asEntity(entityInstance) %>)<%= callBlock %>; + <%= entityInstance %>Repository.<%= saveMethod %>(<%= persistInstance %>)<%= callBlock %>; int databaseSizeBeforeDelete = <%= entityInstance %>Repository.findAll()<%= callListBlock %>.size(); // Delete the <%= entityInstance %> <%_ if (!reactive) { _%> - rest<%= entityClass %>MockMvc.perform(delete(ENTITY_API_URL_ID, <%= asEntity(entityInstance) %>.get<%= primaryKey.nameCapitalized %>()<% if (primaryKey.type === 'UUID' && databaseType === 'sql') { %>.toString()<% } %>)<% if (testsNeedCsrf) { %>.with(csrf())<% }%> + rest<%= entityClass %>MockMvc.perform(delete(ENTITY_API_URL_ID, <%= persistInstance %>.get<%= primaryKey.nameCapitalized %>()<% if (primaryKey.type === 'UUID' && databaseType === 'sql') { %>.toString()<% } %>)<% if (testsNeedCsrf) { %>.with(csrf())<% }%> .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isNoContent()); <%_ } else { _%> - webTestClient.delete().uri(ENTITY_API_URL_ID, <%= asEntity(entityInstance) %>.get<%= primaryKey.nameCapitalized %>()) + webTestClient.delete().uri(ENTITY_API_URL_ID, <%= persistInstance %>.get<%= primaryKey.nameCapitalized %>()) .accept(MediaType.APPLICATION_JSON) .exchange() .expectStatus().isNoContent(); @@ -1580,12 +1580,12 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte <%_ if (databaseType === 'couchbase') { _%> SecurityContextHolder.setContext(TestSecurityContextHolder.getContext()); <%_ } _%> - List<<%= asEntity(entityClass) %>> <%= entityInstance %>List = <%= entityInstance %>Repository.findAll()<%= callListBlock %>; + List<<%= persistClass %>> <%= entityInstance %>List = <%= entityInstance %>Repository.findAll()<%= callListBlock %>; assertThat(<%= entityInstance %>List).hasSize(databaseSizeBeforeDelete - 1); <%_ if (searchEngine === 'elasticsearch') { _%> // Validate the <%= entityClass %> in Elasticsearch - verify(mock<%= entityClass %>SearchRepository, times(1)).deleteById(<%= asEntity(entityInstance) %>.get<%= primaryKey.nameCapitalized %>()); + verify(mock<%= entityClass %>SearchRepository, times(1)).deleteById(<%= persistInstance %>.get<%= primaryKey.nameCapitalized %>()); <%_ } _%> } <%_ } _%> @@ -1605,20 +1605,20 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte <%_ } _%> // Initialize the database <%_ if (primaryKey.type === 'UUID' && databaseType !== 'sql') { _%> - <%= asEntity(entityInstance) %>.set<%= primaryKey.nameCapitalized %>(UUID.randomUUID()); + <%= persistInstance %>.set<%= primaryKey.nameCapitalized %>(UUID.randomUUID()); <%_ } _%> - <%= entityInstance %>Repository.<%= saveMethod %>(<%= asEntity(entityInstance) %>)<%= callBlock %>; + <%= entityInstance %>Repository.<%= saveMethod %>(<%= persistInstance %>)<%= callBlock %>; <%_ if (searchEngine === 'elasticsearch') { _%> <%_ if (reactive) { _%> - when(mock<%= entityClass %>SearchRepository.search("id:" + <%= asEntity(entityInstance) %>.get<%= primaryKey.nameCapitalized %>()<%_ if (pagination !== 'no') { _%>, PageRequest.of(0, 20)<% }%>)) - .thenReturn(Flux.just(<%= asEntity(entityInstance) %>)); + when(mock<%= entityClass %>SearchRepository.search("id:" + <%= persistInstance %>.get<%= primaryKey.nameCapitalized %>()<%_ if (pagination !== 'no') { _%>, PageRequest.of(0, 20)<% }%>)) + .thenReturn(Flux.just(<%= persistInstance %>)); <%_ } else { _%> <%_ if (pagination !== 'no') { _%> - when(mock<%= entityClass %>SearchRepository.search(queryStringQuery("id:" + <%= asEntity(entityInstance) %>.get<%= primaryKey.nameCapitalized %>()), PageRequest.of(0, 20))) - .thenReturn(new PageImpl<>(Collections.singletonList(<%= asEntity(entityInstance) %>), PageRequest.of(0, 1), 1)); + when(mock<%= entityClass %>SearchRepository.search(queryStringQuery("id:" + <%= persistInstance %>.get<%= primaryKey.nameCapitalized %>()), PageRequest.of(0, 20))) + .thenReturn(new PageImpl<>(Collections.singletonList(<%= persistInstance %>), PageRequest.of(0, 1), 1)); <%_ } else { _%> - when(mock<%= entityClass %>SearchRepository.search(queryStringQuery("id:" + <%= asEntity(entityInstance) %>.get<%= primaryKey.nameCapitalized %>()))) - .thenReturn(Collections.singletonList(<%= asEntity(entityInstance) %>)); + when(mock<%= entityClass %>SearchRepository.search(queryStringQuery("id:" + <%= persistInstance %>.get<%= primaryKey.nameCapitalized %>()))) + .thenReturn(Collections.singletonList(<%= persistInstance %>)); <%_ } _%> <%_ } _%> <%_ } else if (searchEngine === 'couchbase') { _%> @@ -1629,11 +1629,11 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte // Search the <%= entityInstance %> <%_ if (!reactive) { _%> - rest<%= entityClass %>MockMvc.perform(get(ENTITY_SEARCH_API_URL + "?query=id:" + <%= asEntity(entityInstance) %>.get<%= primaryKey.nameCapitalized %>())) + rest<%= entityClass %>MockMvc.perform(get(ENTITY_SEARCH_API_URL + "?query=id:" + <%= persistInstance %>.get<%= primaryKey.nameCapitalized %>())) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) <%_ } else { _%> - webTestClient.get().uri(ENTITY_SEARCH_API_URL + "?query=id:" + <%= asEntity(entityInstance) %>.get<%= primaryKey.nameCapitalized %>()) + webTestClient.get().uri(ENTITY_SEARCH_API_URL + "?query=id:" + <%= persistInstance %>.get<%= primaryKey.nameCapitalized %>()) .exchange() .expectStatus().isOk() .expectHeader().contentType(MediaType.APPLICATION_JSON) diff --git a/generators/generator-base.js b/generators/generator-base.js index cca7d119353..1e11a8f7fc9 100644 --- a/generators/generator-base.js +++ b/generators/generator-base.js @@ -2563,7 +2563,7 @@ templates: ${JSON.stringify(existingTemplates, null, 2)}`; * @param {String} name entity name */ asEntity(name) { - return name + this.entitySuffix; + return name + (this.entitySuffix || this.jhipsterConfig.entitySuffix || ''); } /** @@ -2571,7 +2571,7 @@ templates: ${JSON.stringify(existingTemplates, null, 2)}`; * @param {String} name entity name */ asDto(name) { - return name + this.dtoSuffix; + return name + (this.dtoSuffix || this.jhipsterConfig.dtoSuffix || ''); } get needleApi() { diff --git a/utils/entity.js b/utils/entity.js index d27857a1e1b..1d678ac838f 100644 --- a/utils/entity.js +++ b/utils/entity.js @@ -112,6 +112,24 @@ function prepareEntityForTemplates(entityWithConfig, generator) { entityNamePlural: pluralize(entityName), }); + const dto = entityWithConfig.dto === 'mapstruct'; + if (dto) { + _.defaults(entityWithConfig, { + dtoClass: generator.asDto(entityWithConfig.entityClass), + dtoInstance: generator.asDto(entityWithConfig.entityInstance), + }); + } + + _.defaults(entityWithConfig, { + persistClass: generator.asEntity(entityWithConfig.entityClass), + persistInstance: generator.asEntity(entityWithConfig.entityInstance), + }); + + _.defaults(entityWithConfig, { + restClass: dto ? entityWithConfig.dtoClass : entityWithConfig.persistClass, + restInstance: dto ? entityWithConfig.dtoInstance : entityWithConfig.persistInstance, + }); + _.defaults(entityWithConfig, { entityNamePluralizedAndSpinalCased: _.kebabCase(entityWithConfig.entityNamePlural), entityClassPlural: _.upperFirst(entityWithConfig.entityNamePlural),