Repository: jhipster/generator-jhipster
Pull request #8649 (2018-10-25 11:10:43)

Feature: entity and dto suffix (#8647)
-   Please make sure the below checklist is followed for Pull Requests.

-   [x] [Travis tests](https://travis-ci.org/jhipster/generator-jhipster/pull_requests) are green
-   [x] Tests are added where necessary
-   [x] Documentation is added/updated where necessary
-   [x] Coding Rules & Commit Guidelines as per our [CONTRIBUTING.md document](https://github.com/jhipster/generator-jhipster/blob/master/CONTRIBUTING.md) are followed

PR for #8647 

mselerin: Documentation done !
https://github.com/jhipster/jhipster.github.io/pull/654
MathieuAA: In the docs, it says that the suffixes can take two types for values:
  - a string (for an actual, non-empty suffix)
  - false (for no suffix)

Why not just an empty string?
mselerin: > In the docs, it says that the suffixes can take two types for values:
> 
> * a string (for an actual, non-empty suffix)
> * false (for no suffix)
> 
> Why not just an empty string?

Because it seems not possible to specify an empty string inside the JDL. But if there's a way, I'll take it :-)
MathieuAA: Okay, there may be a mismatch between what's generated in JCore (in the JSON entity files) and what's generated by the generator. I'll update JCore to only output empty strings.

DanielFran: @mselerin do not forget to update PR in accordance with the changes from Mathieu.
MathieuAA: @DanielFran There's nothing to change here (already done in JCore). That's why I asked the question: I was afraid of a potential value/type mismatch between the generated JSON files from JCore and here, but the issue only was in JCore, so nothing to do :)
mselerin: BTW, the suffixes are not present in the JSON entity files. These parameters are application-wide, therefore only present inside the `.yo-rc.json` file.

And to be complete, an empty value inside `.yo-rc.json` is stored like this : 

```json
"dtoSuffix": ""
```

The `false` value is only needed inside a JDL file.
DanielFran: @MathieuAA I was refering for the documentário 😎
MathieuAA: Ahhhhh!Okay :)
deepu105: @jhipster/developers I'm tight on time can someone test and merge this?
pascalgrimaud: @deepu105 : we have our JHipster day at Ippon, this tuesday. I think our priority will be to test and merge all pending PR ; then try to reduce the number of opened tickets.

I'll try to help for this
MathieuAA: Yep :)
mselerin: @MathieuAA all changes are done :-)
MathieuAA: Awesome
deepu105: shit seems like we merged the docs but not the PR
deepu105: @jhipster/developers can someone test this please
deepu105: @mselerin could you enable this in one of the travis test entity?
mselerin: @deepu105 OK, I'll update the tests ASAP.

BTW, I've merge the master in the PR to keep it up-to-date ;-)
mselerin: I have detected another error when generating a new app with entity suffix and an entity linked to the `User` entity.

The User entity is generated with the `server` sub-generator and doesn't respect the suffixes. So, when a new entity has a relation with User, it assumes that the class name would be `UserEntity` (if the entity suffix is 'Entity').

@deepu105, what do you think ? Should I modify the server generator as well ?
mselerin: I have resolved the conflict with master (but messed on my first attempt, so had to rewrite history on my branch, :/)

Patch:
diff --git a/generators/app/index.js b/generators/app/index.js
index 0c481517e7..1fbf47f1f4 100644
--- a/generators/app/index.js
+++ b/generators/app/index.js
@@ -98,6 +98,20 @@ module.exports = class extends BaseGenerator {
             defaults: 'jhi'
         });
 
+        // This adds support for a `--entity-suffix` flag
+        this.option('entity-suffix', {
+            desc: 'Add suffix after entities name',
+            type: String,
+            defaults: ''
+        });
+
+        // This adds support for a `--dto-suffix` flag
+        this.option('dto-suffix', {
+            desc: 'Add suffix after dtos name',
+            type: String,
+            defaults: 'DTO'
+        });
+
         // This adds support for a `--yarn` flag
         this.option('yarn', {
             desc: 'Use yarn instead of npm',
@@ -162,6 +176,15 @@ module.exports = class extends BaseGenerator {
         this.skipCheckLengthOfIdentifier = this.configOptions.skipCheckLengthOfIdentifier =
             this.options['skip-check-length-of-identifier'] || this.config.get('skipCheckLengthOfIdentifier');
         this.jhiPrefix = this.configOptions.jhiPrefix = _.camelCase(this.config.get('jhiPrefix') || this.options['jhi-prefix']);
+
+        this.entitySuffix = this.configOptions.entitySuffix = _.isNil(this.config.get('entitySuffix'))
+            ? this.options['entity-suffix']
+            : this.config.get('entitySuffix');
+
+        this.dtoSuffix = this.configOptions.dtoSuffix = _.isNil(this.config.get('dtoSuffix'))
+            ? this.options['dto-suffix']
+            : this.config.get('dtoSuffix');
+
         this.withEntities = this.options['with-entities'];
         this.skipChecks = this.options['skip-checks'];
         const blueprint = this.normalizeBlueprintName(this.options.blueprint || this.config.get('blueprint'));
@@ -386,6 +409,8 @@ module.exports = class extends BaseGenerator {
                     baseName: this.baseName,
                     testFrameworks: this.testFrameworks,
                     jhiPrefix: this.jhiPrefix,
+                    entitySuffix: this.entitySuffix,
+                    dtoSuffix: this.dtoSuffix,
                     skipCheckLengthOfIdentifier: this.skipCheckLengthOfIdentifier,
                     otherModules: this.otherModules,
                     enableTranslation: this.enableTranslation,
diff --git a/generators/client/templates/angular/package.json.ejs b/generators/client/templates/angular/package.json.ejs
index 09f059c6a3..b6f8dd8b10 100644
--- a/generators/client/templates/angular/package.json.ejs
+++ b/generators/client/templates/angular/package.json.ejs
@@ -139,9 +139,9 @@
     <%_ otherModules.forEach(module => { _%>
     "<%= module.name %>": "<%= module.version %>",
     <%_ }); _%>
-    "webpack": "4.26.0",
+    "webpack": "4.28.3",
     "webpack-cli": "3.1.2",
-    "webpack-dev-server": "3.1.10",
+    "webpack-dev-server": "3.1.14",
     "webpack-merge": "4.1.4",
     "webpack-notifier": "1.7.0",
     "webpack-visualizer-plugin": "0.1.11",
diff --git a/generators/client/templates/angular/src/main/webapp/app/admin/gateway/gateway.component.ts.ejs b/generators/client/templates/angular/src/main/webapp/app/admin/gateway/gateway.component.ts.ejs
index a326ac1e65..b4992e1697 100644
--- a/generators/client/templates/angular/src/main/webapp/app/admin/gateway/gateway.component.ts.ejs
+++ b/generators/client/templates/angular/src/main/webapp/app/admin/gateway/gateway.component.ts.ejs
@@ -29,7 +29,7 @@ import { GatewayRoute } from './gateway-route.model';
 export class <%=jhiPrefixCapitalized%>GatewayComponent implements OnInit {
 
     gatewayRoutes: GatewayRoute[];
-    updatingRoutes: Boolean;
+    updatingRoutes: boolean;
 
     constructor(
         private gatewayRoutesService: GatewayRoutesService
diff --git a/generators/client/templates/angular/src/main/webapp/app/core/login/login.service.ts.ejs b/generators/client/templates/angular/src/main/webapp/app/core/login/login.service.ts.ejs
index 34d675935d..5083e03387 100644
--- a/generators/client/templates/angular/src/main/webapp/app/core/login/login.service.ts.ejs
+++ b/generators/client/templates/angular/src/main/webapp/app/core/login/login.service.ts.ejs
@@ -21,16 +21,16 @@ import { Injectable } from '@angular/core';
 <%_ if (enableTranslation && authenticationType === 'uaa') { _%>
 import { JhiLanguageService } from 'ng-jhipster';
 import { SessionStorageService } from 'ngx-webstorage';
-import { IUser } from '../user/user.model';
+import { IUser } from 'app/core/user/user.model';
 <%_ } _%>
-import { AccountService } from '../auth/account.service';
+import { AccountService } from 'app/core/auth/account.service';
 <%_ if (authenticationType === 'jwt' || authenticationType === 'uaa') { _%>
-import { AuthServerProvider } from '../auth/auth-jwt.service';
+import { AuthServerProvider } from 'app/core/auth/auth-jwt.service';
 <%_ } else if (authenticationType === 'session' || authenticationType === 'oauth2') { _%>
-import { AuthServerProvider } from '../auth/auth-session.service';
+import { AuthServerProvider } from 'app/core/auth/auth-session.service';
 <%_ } _%>
 <%_ if (websocket === 'spring-websocket') { _%>
-import { <%=jhiPrefixCapitalized%>TrackerService } from '../tracker/tracker.service';
+import { <%=jhiPrefixCapitalized%>TrackerService } from 'app/core/tracker/tracker.service';
 <%_ } _%>
 
 @Injectable({providedIn: 'root'})
diff --git a/generators/client/templates/angular/src/main/webapp/app/home/home.component.ts.ejs b/generators/client/templates/angular/src/main/webapp/app/home/home.component.ts.ejs
index b711897dc3..e261273a40 100644
--- a/generators/client/templates/angular/src/main/webapp/app/home/home.component.ts.ejs
+++ b/generators/client/templates/angular/src/main/webapp/app/home/home.component.ts.ejs
@@ -54,7 +54,7 @@ export class HomeComponent implements OnInit {
     }
 
     ngOnInit() {
-        this.accountService.identity().then((account) => {
+        this.accountService.identity().then((account: Account) => {
             this.account = account;
         });
         <%_ if (authenticationType !== 'oauth2') { _%>
diff --git a/generators/client/templates/angular/src/main/webapp/app/layouts/navbar/navbar.component.ts.ejs b/generators/client/templates/angular/src/main/webapp/app/layouts/navbar/navbar.component.ts.ejs
index baac9efc31..3f1a916188 100644
--- a/generators/client/templates/angular/src/main/webapp/app/layouts/navbar/navbar.component.ts.ejs
+++ b/generators/client/templates/angular/src/main/webapp/app/layouts/navbar/navbar.component.ts.ejs
@@ -28,7 +28,7 @@ import { SessionStorageService } from 'ngx-webstorage';
 
 import { VERSION } from 'app/app.constants';
 import { <% if (enableTranslation) { %>JhiLanguageHelper, <% } %>AccountService, <% if (authenticationType !== 'oauth2') { %>LoginModalService, <% } %>LoginService } from 'app/core';
-import { ProfileService } from '../profiles/profile.service';
+import { ProfileService } from 'app/layouts/profiles/profile.service';
 
 @Component({
     selector: '<%= jhiPrefixDashed %>-navbar',
diff --git a/generators/client/templates/react/package.json.ejs b/generators/client/templates/react/package.json.ejs
index 0220d81dbc..1b51980c89 100644
--- a/generators/client/templates/react/package.json.ejs
+++ b/generators/client/templates/react/package.json.ejs
@@ -50,7 +50,7 @@ limitations under the License.
     "react-transition-group": "2.4.0",
     "reactstrap": "6.4.0",
     "redux": "4.0.0",
-    "redux-devtools": "3.4.1",
+    "redux-devtools": "3.5.0",
     "redux-devtools-dock-monitor": "1.1.3",
     "redux-devtools-log-monitor": "1.4.0",
     "redux-promise-middleware": "5.1.1",
@@ -159,9 +159,9 @@ limitations under the License.
     "tslint-loader": "3.6.0",
     "tslint-react": "3.6.0",
     "typescript": "3.0.1",
-    "webpack": "4.17.1",
-    "webpack-cli": "3.1.0",
-    "webpack-dev-server": "3.1.6",
+    "webpack": "4.28.3",
+    "webpack-cli": "3.1.2",
+    "webpack-dev-server": "3.1.14",
     "webpack-merge": "4.1.4",
     "webpack-notifier": "1.7.0",
     "workbox-webpack-plugin": "3.4.1",
diff --git a/generators/entity-client/templates/angular/src/main/webapp/app/entities/entity-management-update.component.ts.ejs b/generators/entity-client/templates/angular/src/main/webapp/app/entities/entity-management-update.component.ts.ejs
index 027eb2da63..38412f5c23 100644
--- a/generators/entity-client/templates/angular/src/main/webapp/app/entities/entity-management-update.component.ts.ejs
+++ b/generators/entity-client/templates/angular/src/main/webapp/app/entities/entity-management-update.component.ts.ejs
@@ -26,6 +26,7 @@ import { Component, OnInit<% if (fieldsContainImageBlob) { %>, ElementRef<% } %>
 import { ActivatedRoute } from '@angular/router';
 import { HttpResponse, HttpErrorResponse } from '@angular/common/http';
 import { Observable } from 'rxjs';
+import { filter, map } from 'rxjs/operators';
 <%_ if ( fieldsContainDate ) { _%>
 import * as moment from 'moment';
     <%_ if ( fieldsContainInstant || fieldsContainZonedDateTime ) { _%>
@@ -35,7 +36,6 @@ import { DATE_TIME_FORMAT } from 'app/shared/constants/input.constants';
 <%_ if (queries && queries.length > 0 || fieldsContainBlob) { _%>
 import { <% if (queries && queries.length > 0) { %>JhiAlertService, <% } %><% if (fieldsContainBlob) { %>JhiDataUtils<% } %> } from 'ng-jhipster';
 <%_ } _%>
-
 import { I<%= entityAngularName %> } from 'app/shared/model/<%= entityModelFileName %>.model';
 import { <%= entityAngularName %>Service } from './<%= entityFileName %>.service';
 <%_
diff --git a/generators/entity-client/templates/angular/src/main/webapp/app/entities/entity-management.component.ts.ejs b/generators/entity-client/templates/angular/src/main/webapp/app/entities/entity-management.component.ts.ejs
index dfb2760a8a..15439f1679 100644
--- a/generators/entity-client/templates/angular/src/main/webapp/app/entities/entity-management.component.ts.ejs
+++ b/generators/entity-client/templates/angular/src/main/webapp/app/entities/entity-management.component.ts.ejs
@@ -24,6 +24,7 @@ import { ActivatedRoute, Router } from '@angular/router';
 import { ActivatedRoute } from '@angular/router';
 <%_ } _%>
 import { Subscription } from 'rxjs';
+import { filter, map } from 'rxjs/operators';
 import { JhiEventManager, <% if (pagination !== 'no') { %>JhiParseLinks, <% } %>JhiAlertService<% if (fieldsContainBlob) { %>, JhiDataUtils<% } %> } from 'ng-jhipster';
 
 import { I<%= entityAngularName %> } from 'app/shared/model/<%= entityModelFileName %>.model';
diff --git a/generators/entity-client/templates/angular/src/main/webapp/app/entities/entity-management.route.ts.ejs b/generators/entity-client/templates/angular/src/main/webapp/app/entities/entity-management.route.ts.ejs
index 561f555bd3..fd2dbeead3 100644
--- a/generators/entity-client/templates/angular/src/main/webapp/app/entities/entity-management.route.ts.ejs
+++ b/generators/entity-client/templates/angular/src/main/webapp/app/entities/entity-management.route.ts.ejs
@@ -45,7 +45,7 @@ export class <%= entityAngularName %>Resolve implements Resolve<I<%= entityAngul
     constructor(private service: <%= entityAngularName %>Service) {
     }
 
-    resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<<%= entityAngularName %>> {
+    resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<I<%= entityAngularName %>> {
         const id = route.params['id'] ? route.params['id'] : null;
         if (id) {
             return this.service.find(id).pipe(
diff --git a/generators/entity-client/templates/angular/src/main/webapp/app/entities/no-pagination-template.ejs b/generators/entity-client/templates/angular/src/main/webapp/app/entities/no-pagination-template.ejs
index 7359510a35..3ead3dea7d 100644
--- a/generators/entity-client/templates/angular/src/main/webapp/app/entities/no-pagination-template.ejs
+++ b/generators/entity-client/templates/angular/src/main/webapp/app/entities/no-pagination-template.ejs
@@ -46,19 +46,25 @@
         if (this.currentSearch) {
             this.<%= entityInstance %>Service.search({
                 query: this.currentSearch,
-                }).subscribe(
-                    (res: HttpResponse<I<%= entityAngularName %>[]>) => this.<%= entityInstancePlural %> = res.body,
+                }).pipe(
+                    filter((res: HttpResponse<I<%= entityAngularName %>[]>) => res.ok),
+                    map((res: HttpResponse<I<%= entityAngularName %>[]>) => res.body),
+                ).subscribe(
+                    (res: I<%= entityAngularName %>[]) => this.<%= entityInstancePlural %> = res,
                     (res: HttpErrorResponse) => this.onError(res.message)
                 );
             return;
        }
        <%_ } _%>
-        this.<%= entityInstance %>Service.query().subscribe(
-            (res: HttpResponse<I<%= entityAngularName %>[]>) => {
-                this.<%= entityInstancePlural %> = res.body;
-                <%_ if (searchEngine === 'elasticsearch') { _%>
+        this.<%= entityInstance %>Service.query().pipe(
+            filter((res: HttpResponse<I<%= entityAngularName %>[]>) => res.ok),
+            map((res: HttpResponse<I<%= entityAngularName %>[]>) => res.body),
+        ).subscribe(
+            (res: I<%= entityAngularName %>[]) => {
+                this.<%= entityInstancePlural %> = res;
+            <%_ if (searchEngine === 'elasticsearch') { _%>
                 this.currentSearch = '';
-                <%_ } _%>
+            <%_ } _%>
             },
             (res: HttpErrorResponse) => this.onError(res.message)
         );
diff --git a/generators/entity-server/files.js b/generators/entity-server/files.js
index 9a6db02743..e214ab01ef 100644
--- a/generators/entity-server/files.js
+++ b/generators/entity-server/files.js
@@ -78,7 +78,7 @@ const serverFiles = {
             templates: [
                 {
                     file: 'package/domain/Entity.java',
-                    renameTo: generator => `${generator.packageFolder}/domain/${generator.entityClass}.java`
+                    renameTo: generator => `${generator.packageFolder}/domain/${generator.asEntity(generator.entityClass)}.java`
                 },
                 {
                     file: 'package/repository/EntityRepository.java',
@@ -154,7 +154,7 @@ const serverFiles = {
             templates: [
                 {
                     file: 'package/service/dto/EntityDTO.java',
-                    renameTo: generator => `${generator.packageFolder}/service/dto/${generator.entityClass}DTO.java`
+                    renameTo: generator => `${generator.packageFolder}/service/dto/${generator.asDto(generator.entityClass)}.java`
                 },
                 {
                     file: 'package/service/mapper/BaseEntityMapper.java',
@@ -243,7 +243,13 @@ function writeFiles() {
                 this.addChangelogToLiquibase(`${this.changelogDate}_added_entity_${this.entityClass}`);
 
                 if (['ehcache', 'infinispan'].includes(this.cacheProvider) && this.enableHibernateCache) {
-                    this.addEntityToCache(this.entityClass, this.relationships, this.packageName, this.packageFolder, this.cacheProvider);
+                    this.addEntityToCache(
+                        this.asEntity(this.entityClass),
+                        this.relationships,
+                        this.packageName,
+                        this.packageFolder,
+                        this.cacheProvider
+                    );
                 }
             }
         },
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 40bac56661..aa7da8757c 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') ? entityClass + 'DTO' : entityClass;
-    const instanceName = (dto === 'mapstruct') ? entityInstance + 'DTO' : entityInstance;
+    const instanceType = (dto === 'mapstruct') ? asDto(entityClass) : asEntity(entityClass);
+    const instanceName = (dto === 'mapstruct') ? asDto(entityInstance) : asEntity(entityInstance);
     const mapper = entityInstance + 'Mapper';
     const entityListToDtoListReference = mapper + '.' + 'toDto';
     const entityToDtoReference = mapper + '::'+ 'toDto';
@@ -51,7 +51,7 @@
     public List<<%= instanceType %>> getAll<%= entityClassPlural %>(<% if (fieldsContainNoOwnerOneToOne) { %>@RequestParam(required = false) String filter<% } %><% if (fieldsContainOwnerManyToMany && fieldsContainNoOwnerOneToOne) { %>,<% } %><% if (fieldsContainOwnerManyToMany) { %>@RequestParam(required = false, defaultValue = "false") boolean eagerload<% }%>) {<%- include('get_all_stream_template', {viaService: viaService}); -%>
         log.debug("REST request to get all <%= entityClassPlural %>");<% if (viaService) { %>
         return <%= entityInstance %>Service.findAll();<% } else if (dto === 'mapstruct') { %>
-        List<<%= entityClass %>> <%= entityInstancePlural %> = <%= entityInstance %>Repository.<% if (fieldsContainOwnerManyToMany) { %>findAllWithEagerRelationships<% } else { %>findAll<% } %>();
+        List<<%= asEntity(entityClass) %>> <%= entityInstancePlural %> = <%= entityInstance %>Repository.<% if (fieldsContainOwnerManyToMany) { %>findAllWithEagerRelationships<% } else { %>findAll<% } %>();
         return <%= entityListToDtoListReference %>(<%= entityInstancePlural %>);<% } else { %>
         return <%= entityInstance %>Repository.<% if (fieldsContainOwnerManyToMany) { %>findAllWithEagerRelationships<% } else { %>findAll<% } %>();<% } %>
     <%_ } if (pagination !== 'no') { _%>
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 1985f9856f..1205e32804 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') ? entityClass + 'DTO' : entityClass;
+const instanceType = (dto === 'mapstruct') ? asDto(entityClass) : asEntity(entityClass);
 const mapper = entityInstance  + 'Mapper';
 const entityToDtoReference = mapper + '::' + 'toDto';
 for (const idx in relationships) { if (relationships[idx].relationshipType === 'one-to-one' && relationships[idx].ownerSide !== true) { %>
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 de05eb8b42..9e98bcd67a 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
@@ -16,8 +16,8 @@
  See the License for the specific language governing permissions and
  limitations under the License.
 -%>
-<%  const instanceType = (dto === 'mapstruct') ? 'Optional<' + entityClass + 'DTO>' : 'Optional<' + entityClass + '>';
-    const instanceName = (dto === 'mapstruct') ? entityInstance + 'DTO' : entityInstance;
+<%  const instanceType = (dto === 'mapstruct') ? 'Optional<' + asDto(entityClass) + '>' : 'Optional<' + asEntity(entityClass) + '>';
+    const instanceName = (dto === 'mapstruct') ? asDto(entityInstance) : asEntity(entityInstance);
     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/save_template.ejs b/generators/entity-server/templates/src/main/java/package/common/save_template.ejs
index 21f809a1a7..dd6f21be74 100644
--- a/generators/entity-server/templates/src/main/java/package/common/save_template.ejs
+++ b/generators/entity-server/templates/src/main/java/package/common/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') ? entityClass + 'DTO' : entityClass;
-const instanceName = (dto === 'mapstruct') ? entityInstance + 'DTO' : entityInstance;
+<%_ const instanceType = (dto === 'mapstruct') ? asDto(entityClass) : asEntity(entityClass);
+const instanceName = (dto === 'mapstruct') ? asDto(entityInstance) : asEntity(entityInstance);
 const mapper = entityInstance  + 'Mapper';
 const dtoToEntity = mapper + '.' + 'toEntity';
 const entityToDto = mapper + '.' + 'toDto';
@@ -25,12 +25,12 @@ const returnPrefix = (returnDirectly && searchEngine !== 'elasticsearch') ? 'ret
 let resultEntity;
 if (!viaService) {
     if (dto === 'mapstruct') {
-        resultEntity = entityInstance; %>
-        <%= entityClass %> <%= entityInstance %> = <%= dtoToEntity %>(<%= instanceName %>);
-        <%= entityInstance %> = <%= entityInstance %>Repository.save(<%= entityInstance %>);
-        <%= returnPrefix %> <%= entityToDto %>(<%= entityInstance %>);
+        resultEntity = asEntity(entityInstance); %>
+        <%= asEntity(entityClass) %> <%= asEntity(entityInstance) %> = <%= dtoToEntity %>(<%= instanceName %>);
+        <%= asEntity(entityInstance) %> = <%= entityInstance %>Repository.save(<%= asEntity(entityInstance) %>);
+        <%= returnPrefix %> <%= entityToDto %>(<%= asEntity(entityInstance) %>);
     <%_ } else { resultEntity = 'result'; _%>
-        <%= returnPrefix %> <%= entityInstance %>Repository.save(<%= entityInstance %>);
+        <%= returnPrefix %> <%= entityInstance %>Repository.save(<%= asEntity(entityInstance) %>);
         <%_ } if (searchEngine === 'elasticsearch') { _%>
         <%= entityInstance %>SearchRepository.save(<%= resultEntity %>);
             <%_ if (returnDirectly) { _%>
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 314239c19f..2677ef7a0b 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') ? entityClass + 'DTO' : entityClass;
-    const instanceName = (dto === 'mapstruct') ? entityInstance + 'DTO' : entityInstance;
+    const instanceType = (dto === 'mapstruct') ? asDto(entityClass) : asEntity(entityClass);
+    const instanceName = (dto === 'mapstruct') ? asDto(entityInstance) : asEntity(entityInstance);
     const mapper = entityInstance + 'Mapper';
     const entityToDtoReference = mapper + '::' + 'toDto';
     const entityListToDtoListReference = mapper + '.' + 'toDto';
@@ -29,8 +29,8 @@
     public ResponseEntity<List<<%= instanceType %>>> search<%= entityClassPlural %>(@RequestParam String query, Pageable pageable) {
         log.debug("REST request to search for a page of <%= entityClassPlural %> for query {}", query);<% if (viaService) { %>
         Page<<%= instanceType %>> page = <%= entityInstance %>Service.search(query, pageable);<% } else { %>
-        Page<<%= entityClass %>> page = <%= entityInstance %>SearchRepository.search(queryStringQuery(query), pageable);<% } %>
+        Page<<%= asEntity(entityClass) %>> page = <%= entityInstance %>SearchRepository.search(queryStringQuery(query), pageable);<% } %>
         HttpHeaders headers = PaginationUtil.generateSearchPaginationHttpHeaders(query, page, "/api/_search/<%= entityApiUrl %>");
-        return new ResponseEntity<>(<% if (!viaService && dto === 'mapstruct') { %><%= entityListToDtoListReference %>(page.getContent())<% } else { %>page.getContent()<% } %>, headers, HttpStatus.OK);
+        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 5e5f6d313c..3248537724 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
@@ -92,7 +92,7 @@ import static org.springframework.data.couchbase.core.mapping.id.GenerationStrat
 <%_ } _%>
 <%_ if (typeof javadoc == 'undefined') { _%>
 /**
- * A <%= entityClass %>.
+ * A <%= asEntity(entityClass) %>.
  */
 <%_ } else { _%>
 <%- formatAsClassJavadoc(javadoc) %>
@@ -119,7 +119,7 @@ import static org.springframework.data.couchbase.core.mapping.id.GenerationStrat
 <%_ } if (searchEngine === 'elasticsearch' && databaseType !== 'mongodb') { _%>
 @Document(indexName = "<%= entityInstance.toLowerCase() %>")
 <%_ } _%>
-public class <%= entityClass %> implements Serializable {
+public class <%= asEntity(entityClass) %> implements Serializable {
 
     private static final long serialVersionUID = 1L;
     <%_ if (databaseType === 'couchbase') { _%>
@@ -243,7 +243,7 @@ public class <%= entityClass %> implements Serializable {
     @DBRef
     @Field("<%= relationshipFieldName %>")
     <%_ } _%>
-    private Set<<%= otherEntityNameCapitalized %>> <%= relationshipFieldNamePlural %> = new HashSet<>();
+    private Set<<%= asEntity(otherEntityNameCapitalized) %>> <%= relationshipFieldNamePlural %> = new HashSet<>();
     <%_ } else if (relationshipType === 'many-to-one') {
             if (databaseType === 'sql') {
     _%>
@@ -256,7 +256,7 @@ public class <%= entityClass %> implements Serializable {
     @Field("<%= relationshipFieldName %>")
     <%_ } _%>
     @JsonIgnoreProperties("<%= otherEntityRelationshipNamePlural %>")
-    private <%= otherEntityNameCapitalized %> <%= relationshipFieldName %>;
+    private <%= asEntity(otherEntityNameCapitalized) %> <%= relationshipFieldName %>;
 
     <%_ } else if (relationshipType === 'many-to-many') {
         if (databaseType === 'sql') { _%>
@@ -281,7 +281,7 @@ public class <%= entityClass %> implements Serializable {
     <%_ } if (ownerSide === false) { _%>
     @JsonIgnore
     <%_ } _%>
-    private Set<<%= otherEntityNameCapitalized %>> <%= relationshipFieldNamePlural %> = new HashSet<>();
+    private Set<<%= asEntity(otherEntityNameCapitalized) %>> <%= relationshipFieldNamePlural %> = new HashSet<>();
 
     <%_ } else {
         if (databaseType === 'sql') {
@@ -302,7 +302,7 @@ public class <%= entityClass %> implements Serializable {
     @com.fasterxml.jackson.annotation.JsonBackReference
     <%_     }
         } _%>
-    private <%= otherEntityNameCapitalized %> <%= relationshipFieldName %>;
+    private <%= asEntity(otherEntityNameCapitalized) %> <%= relationshipFieldName %>;
 
     <%_ }
     } _%>
@@ -330,9 +330,9 @@ public class <%= entityClass %> implements Serializable {
     <%_ if (fluentMethods) { _%>
 
         <%_ if (fieldTypeBlobContent !== 'text') { _%>
-    public <%= entityClass %> <%= fieldName %>(<%= fieldType %> <%= fieldName %>) {
+    public <%= asEntity(entityClass) %> <%= fieldName %>(<%= fieldType %> <%= fieldName %>) {
         <%_ } else { _%>
-    public <%= entityClass %> <%= fieldName %>(String <%= fieldName %>) {
+    public <%= asEntity(entityClass) %> <%= fieldName %>(String <%= fieldName %>) {
         <%_ } _%>
         this.<%= fieldName %> = <%= fieldName %>;
         return this;
@@ -353,7 +353,7 @@ public class <%= entityClass %> implements Serializable {
     }
     <%_ if (fluentMethods) { _%>
 
-    public <%= entityClass %> <%= fieldName %>ContentType(String <%= fieldName %>ContentType) {
+    public <%= asEntity(entityClass) %> <%= fieldName %>ContentType(String <%= fieldName %>ContentType) {
         this.<%= fieldName %>ContentType = <%= fieldName %>ContentType;
         return this;
     }
@@ -379,17 +379,17 @@ public class <%= entityClass %> implements Serializable {
     _%>
     <%_ if (relationshipType === 'one-to-many' || relationshipType === 'many-to-many') { _%>
 
-    public Set<<%= otherEntityNameCapitalized %>> get<%= relationshipNameCapitalizedPlural %>() {
+    public Set<<%= asEntity(otherEntityNameCapitalized) %>> get<%= relationshipNameCapitalizedPlural %>() {
         return <%= relationshipFieldNamePlural %>;
     }
         <%_ if (fluentMethods) { _%>
 
-    public <%= entityClass %> <%= relationshipFieldNamePlural %>(Set<<%= otherEntityNameCapitalized %>> <%= otherEntityNamePlural %>) {
+    public <%= asEntity(entityClass) %> <%= relationshipFieldNamePlural %>(Set<<%= asEntity(otherEntityNameCapitalized) %>> <%= otherEntityNamePlural %>) {
         this.<%= relationshipFieldNamePlural %> = <%= otherEntityNamePlural %>;
         return this;
     }
 
-    public <%= entityClass %> add<%= relationshipNameCapitalized %>(<%= otherEntityNameCapitalized %> <%= otherEntityName %>) {
+    public <%= asEntity(entityClass) %> add<%= relationshipNameCapitalized %>(<%= asEntity(otherEntityNameCapitalized) %> <%= otherEntityName %>) {
         this.<%= relationshipFieldNamePlural %>.add(<%= otherEntityName %>);
             <%_ if (relationshipType === 'one-to-many') { _%>
         <%= otherEntityName %>.set<%= otherEntityRelationshipNameCapitalized %>(this);
@@ -400,7 +400,7 @@ public class <%= entityClass %> implements Serializable {
         return this;
     }
 
-    public <%= entityClass %> remove<%= relationshipNameCapitalized %>(<%= otherEntityNameCapitalized %> <%= otherEntityName %>) {
+    public <%= asEntity(entityClass) %> remove<%= relationshipNameCapitalized %>(<%= asEntity(otherEntityNameCapitalized) %> <%= otherEntityName %>) {
         this.<%= relationshipFieldNamePlural %>.remove(<%= otherEntityName %>);
             <%_ if (relationshipType === 'one-to-many') { _%>
         <%= otherEntityName %>.set<%= otherEntityRelationshipNameCapitalized %>(null);
@@ -412,23 +412,23 @@ public class <%= entityClass %> implements Serializable {
     }
         <%_ } _%>
 
-    public void set<%= relationshipNameCapitalizedPlural %>(Set<<%= otherEntityNameCapitalized %>> <%= otherEntityNamePlural %>) {
+    public void set<%= relationshipNameCapitalizedPlural %>(Set<<%= asEntity(otherEntityNameCapitalized) %>> <%= otherEntityNamePlural %>) {
         this.<%= relationshipFieldNamePlural %> = <%= otherEntityNamePlural %>;
     }
     <%_ } else { _%>
 
-    public <%= otherEntityNameCapitalized %> get<%= relationshipNameCapitalized %>() {
+    public <%= asEntity(otherEntityNameCapitalized) %> get<%= relationshipNameCapitalized %>() {
         return <%= relationshipFieldName %>;
     }
         <%_ if (fluentMethods) { _%>
 
-    public <%= entityClass %> <%= relationshipFieldName %>(<%= otherEntityNameCapitalized %> <%= otherEntityName %>) {
+    public <%= asEntity(entityClass) %> <%= relationshipFieldName %>(<%= asEntity(otherEntityNameCapitalized) %> <%= otherEntityName %>) {
         this.<%= relationshipFieldName %> = <%= otherEntityName %>;
         return this;
     }
         <%_ } _%>
 
-    public void set<%= relationshipNameCapitalized %>(<%= otherEntityNameCapitalized %> <%= otherEntityName %>) {
+    public void set<%= relationshipNameCapitalized %>(<%= asEntity(otherEntityNameCapitalized) %> <%= otherEntityName %>) {
         this.<%= relationshipFieldName %> = <%= otherEntityName %>;
     }
     <%_ } _%>
@@ -443,7 +443,7 @@ public class <%= entityClass %> implements Serializable {
         if (o == null || getClass() != o.getClass()) {
             return false;
         }
-        <%= entityClass %> <%= entityInstance %> = (<%= entityClass %>) o;
+        <%= asEntity(entityClass) %> <%= entityInstance %> = (<%= asEntity(entityClass) %>) o;
         if (<%= entityInstance %>.getId() == null || getId() == null) {
             return false;
         }
@@ -457,7 +457,7 @@ public class <%= entityClass %> implements Serializable {
 
     @Override
     public String toString() {
-        return "<%= entityClass %>{" +
+        return "<%= asEntity(entityClass) %>{" +
             "id=" + getId() +
             <%_ for (idx in fields) {
                 const fieldType = fields[idx].fieldType;
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 8ab2ceb53a..96da684b08 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.<%=entityClass%>;
+import <%=packageName%>.domain.<%=asEntity(entityClass)%>;
 <%_ if (fieldsContainOwnerManyToMany) { _%>
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
@@ -58,42 +58,42 @@ import java.util.UUID;
 <%_ } _%>
 
 /**
- * Spring Data <% if (databaseType === 'mongodb') { %>MongoDB<% } if (databaseType === 'couchbase') { %>Couchbase<% } if (databaseType === 'cassandra') { %>Cassandra<% } %> repository for the <%= entityClass %> entity.
+ * Spring Data <% if (databaseType === 'mongodb') { %>MongoDB<% } if (databaseType === 'couchbase') { %>Couchbase<% } if (databaseType === 'cassandra') { %>Cassandra<% } %> repository for the <%= asEntity(entityClass) %> entity.
  */
 @SuppressWarnings("unused")
 @Repository
-public interface <%=entityClass%>Repository extends <% if (databaseType === 'sql') { %>JpaRepository<% } %><% if (databaseType === 'mongodb') { %>MongoRepository<% } %><% if (databaseType === 'cassandra') { %>CassandraRepository<% } %><% if (databaseType === 'couchbase') { %>N1qlCouchbaseRepository<% } %><<%=entityClass%>, <%= pkType %>><% if (jpaMetamodelFiltering) { %>, JpaSpecificationExecutor<<%=entityClass%>><% } %> {
+public interface <%=entityClass%>Repository extends <% if (databaseType === 'sql') { %>JpaRepository<% } %><% if (databaseType === 'mongodb') { %>MongoRepository<% } %><% if (databaseType === 'cassandra') { %>CassandraRepository<% } %><% if (databaseType === 'couchbase') { %>N1qlCouchbaseRepository<% } %><<%=asEntity(entityClass)%>, <%= pkType %>><% if (jpaMetamodelFiltering) { %>, JpaSpecificationExecutor<<%=asEntity(entityClass)%>><% } %> {
     <%_ for (idx in relationships) {
         if (relationships[idx].relationshipType === 'many-to-one' && relationships[idx].otherEntityName === 'user' && databaseType === 'sql') { _%>
 
-    @Query("select <%= entityTableName %> from <%= entityClass %> <%= entityTableName %> where <%= entityTableName %>.<%= relationships[idx].relationshipFieldName %>.login = ?#{principal.username}")
-    List<<%= entityClass %>> findBy<%= relationships[idx].relationshipNameCapitalized %>IsCurrentUser();
+    @Query("select <%= entityTableName %> from <%= asEntity(entityClass) %> <%= entityTableName %> where <%= entityTableName %>.<%= relationships[idx].relationshipFieldName %>.login = ?#{principal.username}")
+    List<<%= asEntity(entityClass) %>> findBy<%= relationships[idx].relationshipNameCapitalized %>IsCurrentUser();
     <%_ } } _%>
     <%_ if (fieldsContainOwnerManyToMany === true) {
         if (databaseType === 'sql') { _%>
 
-    @Query(value = "select distinct <%= entityTableName %> from <%= entityClass %> <%= entityTableName %><% for (idx in relationships) {
+    @Query(value = "select distinct <%= entityTableName %> from <%= asEntity(entityClass) %> <%= entityTableName %><% for (idx in relationships) {
     if (relationships[idx].relationshipType === 'many-to-many' && relationships[idx].ownerSide === true) { %> left join fetch <%=entityTableName%>.<%=relationships[idx].relationshipFieldNamePlural%><%} }%>",
-        countQuery = "select count(distinct <%= entityTableName %>) from <%= entityClass %> <%= entityTableName %>")
-    Page<<%=entityClass%>> findAllWithEagerRelationships(Pageable pageable);
+        countQuery = "select count(distinct <%= entityTableName %>) from <%= asEntity(entityClass) %> <%= entityTableName %>")
+    Page<<%=asEntity(entityClass)%>> findAllWithEagerRelationships(Pageable pageable);
 
-    @Query(value = "select distinct <%= entityTableName %> from <%= entityClass %> <%= entityTableName %><% for (idx in relationships) {
+    @Query(value = "select distinct <%= entityTableName %> from <%= asEntity(entityClass) %> <%= entityTableName %><% for (idx in relationships) {
     if (relationships[idx].relationshipType === 'many-to-many' && relationships[idx].ownerSide === true) { %> left join fetch <%=entityTableName%>.<%=relationships[idx].relationshipFieldNamePlural%><%} }%>")
-    List<<%=entityClass%>> findAllWithEagerRelationships();
+    List<<%=asEntity(entityClass)%>> findAllWithEagerRelationships();
 
-    @Query("select <%= entityTableName %> from <%= entityClass %> <%= entityTableName %><% for (idx in relationships) {
+    @Query("select <%= entityTableName %> from <%= asEntity(entityClass) %> <%= entityTableName %><% for (idx in relationships) {
     if (relationships[idx].relationshipType === 'many-to-many' && relationships[idx].ownerSide === true) { %> left join fetch <%=entityTableName%>.<%=relationships[idx].relationshipFieldNamePlural%><%} }%> where <%=entityTableName%>.id =:id")
-    Optional<<%=entityClass%>> findOneWithEagerRelationships(@Param("id") <%= pkType %> id);
+    Optional<<%=asEntity(entityClass)%>> findOneWithEagerRelationships(@Param("id") <%= pkType %> id);
     <%_
         } else if (databaseType === 'mongodb')  { _%>
     @Query("{}")
-    Page<<%=entityClass%>> findAllWithEagerRelationships(Pageable pageable);
+    Page<<%=asEntity(entityClass)%>> findAllWithEagerRelationships(Pageable pageable);
 
     @Query("{}")
-    List<<%=entityClass%>> findAllWithEagerRelationships();
+    List<<%=asEntity(entityClass)%>> findAllWithEagerRelationships();
 
     @Query("{'id': ?0}")
-    Optional<<%=entityClass%>> findOneWithEagerRelationships(<%= pkType %> id);
+    Optional<<%=asEntity(entityClass)%>> findOneWithEagerRelationships(<%= pkType %> id);
     <%_ }
     } _%>
 
diff --git a/generators/entity-server/templates/src/main/java/package/repository/reactive/EntityReactiveRepository.java.ejs b/generators/entity-server/templates/src/main/java/package/repository/reactive/EntityReactiveRepository.java.ejs
index e8d149b502..ae44048dfb 100644
--- a/generators/entity-server/templates/src/main/java/package/repository/reactive/EntityReactiveRepository.java.ejs
+++ b/generators/entity-server/templates/src/main/java/package/repository/reactive/EntityReactiveRepository.java.ejs
@@ -18,7 +18,7 @@
 -%>
 package <%= packageName %>.repository.reactive;
 
-import <%= packageName %>.domain.<%= entityClass %>;
+import <%= packageName %>.domain.<%= asEntity(entityClass) %>;
 <%_ if (databaseType === 'cassandra') { _%>
 import org.springframework.data.cassandra.repository.ReactiveCassandraRepository;
 <%_ } _%>
@@ -39,15 +39,15 @@ import java.util.UUID;
 <%_ } _%>
 
 /**
- * Spring Data <% if (databaseType === 'mongodb') { %>MongoDB<% } if (databaseType === 'couchbase') { %>Couchbase<% } if (databaseType === 'cassandra') { %>Cassandra<% } %> reactive repository for the <%= entityClass %> entity.
+ * Spring Data <% if (databaseType === 'mongodb') { %>MongoDB<% } if (databaseType === 'couchbase') { %>Couchbase<% } if (databaseType === 'cassandra') { %>Cassandra<% } %> reactive repository for the <%= asEntity(entityClass) %> entity.
  */
 @SuppressWarnings("unused")
 @Repository
-public interface <%= entityClass %>ReactiveRepository extends Reactive<% if (databaseType === 'mongodb') { %>Mongo<% } if (databaseType === 'couchbase') { %>CouchbaseSorting<% } if (databaseType === 'cassandra') { %>Cassandra<% } %>Repository<<%= entityClass %>, <%= pkType %>> {
+public interface <%= entityClass %>ReactiveRepository extends Reactive<% if (databaseType === 'mongodb') { %>Mongo<% } if (databaseType === 'couchbase') { %>CouchbaseSorting<% } if (databaseType === 'cassandra') { %>Cassandra<% } %>Repository<<%= asEntity(entityClass) %>, <%= pkType %>> {
     <%_ if (databaseType === 'couchbase') { _%>
 
     @Query("#{#n1ql.selectEntity} WHERE #{#n1ql.filter}")
-    Flux<<%= entityClass %>> findAll();
+    Flux<<%= asEntity(entityClass) %>> findAll();
 
     <%_ } _%>
 }
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 75d7668b45..616358f746 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,13 +18,13 @@
 -%>
 package <%=packageName%>.repository.search;
 
-import <%=packageName%>.domain.<%=entityClass%>;
+import <%=packageName%>.domain.<%=asEntity(entityClass)%>;
 import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;<% if (databaseType === 'cassandra') { %>
 
 import java.util.UUID;<% } %>
 
 /**
- * Spring Data Elasticsearch repository for the <%=entityClass%> entity.
+ * Spring Data Elasticsearch repository for the <%=asEntity(entityClass)%> entity.
  */
-public interface <%=entityClass%>SearchRepository extends ElasticsearchRepository<<%=entityClass%>, <% if (databaseType === 'sql') { %>Long<% } %><% if (databaseType === 'mongodb' || databaseType === 'couchbase') { %>String<% } %><% if (databaseType === 'cassandra') { %>UUID<% } %>> {
+public interface <%=entityClass%>SearchRepository extends ElasticsearchRepository<<%=asEntity(entityClass)%>, <% if (databaseType === 'sql') { %>Long<% } %><% if (databaseType === 'mongodb' || databaseType === 'couchbase') { %>String<% } %><% if (databaseType === 'cassandra') { %>UUID<% } %>> {
 }
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 af07449d5f..1557265ec2 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
@@ -19,8 +19,8 @@
 package <%=packageName%>.service;
 
 <%_ const serviceClassName = entityClass + 'QueryService';
-    const instanceType = (dto === 'mapstruct') ? entityClass + 'DTO' : entityClass;
-    const instanceName = (dto === 'mapstruct') ? entityInstance + 'DTO' : entityInstance;
+    const instanceType = (dto === 'mapstruct') ? asDto(entityClass) : asEntity(entityClass);
+    const instanceName = (dto === 'mapstruct') ? asDto(entityInstance) : asEntity(entityInstance);
     const mapper = entityInstance  + 'Mapper';
     const dtoToEntity = mapper + '.'+ 'toEntity';
     const entityToDto = mapper + '.'+ 'toDto';
@@ -42,13 +42,13 @@ import org.springframework.transaction.annotation.Transactional;
 
 import io.github.jhipster.service.QueryService;
 
-import <%=packageName%>.domain.<%= entityClass %>;
+import <%=packageName%>.domain.<%= asEntity(entityClass) %>;
 import <%=packageName%>.domain.*; // for static metamodels
 import <%=packageName%>.repository.<%= entityClass %>Repository;<% if (searchEngine === 'elasticsearch') { %>
 import <%=packageName%>.repository.search.<%= entityClass %>SearchRepository;<% } %>
 import <%=packageName%>.service.dto.<%= entityClass %>Criteria;
 <%_ if (dto === 'mapstruct') { _%>
-import <%=packageName%>.service.dto.<%= entityClass %>DTO;
+import <%=packageName%>.service.dto.<%= asDto(entityClass) %>;
 import <%=packageName%>.service.mapper.<%= entityClass %>Mapper;
 <%_ } _%>
 
@@ -60,7 +60,7 @@ import <%=packageName%>.service.mapper.<%= entityClass %>Mapper;
  */
 @Service<% if (databaseType === 'sql') { %>
 @Transactional(readOnly = true)<% } %>
-public class <%= serviceClassName %> extends QueryService<<%= entityClass %>> {
+public class <%= serviceClassName %> extends QueryService<<%= asEntity(entityClass) %>> {
 
     private final Logger log = LoggerFactory.getLogger(<%= serviceClassName %>.class);
 <%- include('../common/inject_template', {viaService: false, constructorName: serviceClassName, queryService: false}); -%>
@@ -73,7 +73,7 @@ public class <%= serviceClassName %> extends QueryService<<%= entityClass %>> {
     @Transactional(readOnly = true)
     public List<<%= instanceType %>> findByCriteria(<%= criteria %> criteria) {
         log.debug("find by criteria : {}", criteria);
-        final Specification<<%= entityClass %>> specification = createSpecification(criteria);
+        final Specification<<%= asEntity(entityClass) %>> specification = createSpecification(criteria);
     <%_ if (dto === 'mapstruct') { _%>
         return <%= entityListToDto %>(<%= repository %>.findAll(specification));
     <%_ } else { _%>
@@ -90,7 +90,7 @@ public class <%= serviceClassName %> extends QueryService<<%= entityClass %>> {
     @Transactional(readOnly = true)
     public Page<<%= instanceType %>> findByCriteria(<%= criteria %> criteria, Pageable page) {
         log.debug("find by criteria : {}, page: {}", criteria, page);
-        final Specification<<%= entityClass %>> specification = createSpecification(criteria);
+        final Specification<<%= asEntity(entityClass) %>> specification = createSpecification(criteria);
     <%_ if (dto === 'mapstruct') { _%>
         return <%= repository %>.findAll(specification, page)
             .map(<%= entityToDtoReference %>);
@@ -107,24 +107,24 @@ public class <%= serviceClassName %> extends QueryService<<%= entityClass %>> {
     @Transactional(readOnly = true)
     public long countByCriteria(<%= criteria %> criteria) {
         log.debug("count by criteria : {}", criteria);
-        final Specification<<%= entityClass %>> specification = createSpecification(criteria);
+        final Specification<<%= asEntity(entityClass) %>> specification = createSpecification(criteria);
         return <%= repository %>.count(specification);
     }
 
     /**
      * Function to convert <%= criteria %> to a {@link Specification}
      */
-    private Specification<<%= entityClass %>> createSpecification(<%= criteria %> criteria) {
-        Specification<<%= entityClass %>> specification = Specification.where(null);
+    private Specification<<%= asEntity(entityClass) %>> createSpecification(<%= criteria %> criteria) {
+        Specification<<%= asEntity(entityClass) %>> specification = Specification.where(null);
         if (criteria != null) {
             if (criteria.getId() != null) {
-                specification = specification.and(buildSpecification(criteria.getId(), <%= entityClass %>_.id));
+                specification = specification.and(buildSpecification(criteria.getId(), <%= asEntity(entityClass) %>_.id));
             }
             <%_
             fields.forEach((field) => {
                 if (isFilterableType(field.fieldType)) { _%>
             if (criteria.get<%= field.fieldInJavaBeanMethod %>() != null) {
-                specification = specification.and(<%= getSpecificationBuilder(field.fieldType) %>(criteria.get<%= field.fieldInJavaBeanMethod %>(), <%= entityClass %>_.<%= field.fieldName %>));
+                specification = specification.and(<%= getSpecificationBuilder(field.fieldType) %>(criteria.get<%= field.fieldInJavaBeanMethod %>(), <%= asEntity(entityClass) %>_.<%= field.fieldName %>));
             }
             <%_ }
             });
@@ -133,7 +133,7 @@ public class <%= serviceClassName %> extends QueryService<<%= entityClass %>> {
                 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(<%= entityClass %>_.<%= metamodelFieldName %>, JoinType.LEFT).get(<%= relationship.otherEntityNameCapitalized %>_.id)));
+                    root -> root.join(<%= asEntity(entityClass) %>_.<%= metamodelFieldName %>, JoinType.LEFT).get(<%= asEntity(relationship.otherEntityNameCapitalized) %>_.id)));
             }
             <%_ }); // 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 b77e2a0d0a..2e62f6440d 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
@@ -17,12 +17,12 @@
  limitations under the License.
 -%>
 package <%=packageName%>.service;
-<%  const instanceType = (dto === 'mapstruct') ? entityClass + 'DTO' : entityClass;
-    const instanceName = (dto === 'mapstruct') ? entityInstance + 'DTO' : entityInstance; %>
+<%  const instanceType = (dto === 'mapstruct') ? asDto(entityClass) : asEntity(entityClass);
+    const instanceName = (dto === 'mapstruct') ? asDto(entityInstance) : asEntity(entityInstance); %>
 <%_ if (dto === 'mapstruct') { _%>
-import <%=packageName%>.service.dto.<%= entityClass %>DTO;
+import <%=packageName%>.service.dto.<%= asDto(entityClass) %>;
 <%_ } else { _%>
-import <%=packageName%>.domain.<%= entityClass %>;
+import <%=packageName%>.domain.<%= asEntity(entityClass) %>;
 <%_ } _%>
 <%_ if (pagination !== 'no' || fieldsContainOwnerManyToMany === true) { _%>
 
@@ -63,7 +63,7 @@ public interface <%= entityClass %>Service {
     <% if (pagination !== 'no') { %>Page<<%= instanceType %><% } else { %>List<<%= instanceType %><% } %>> findAll(<% if (pagination !== 'no') { %>Pageable pageable<% } %>);
 <% for (idx in relationships) { if (relationships[idx].relationshipType === 'one-to-one' && relationships[idx].ownerSide !== true) { -%>
     /**
-     * Get all the <%= entityClass %>DTO where <%= relationships[idx].relationshipNameCapitalized %> is null.
+     * Get all the <%= asDto(entityClass) %> where <%= relationships[idx].relationshipNameCapitalized %> is null.
      *
      * @return the list of entities
      */
diff --git a/generators/entity-server/templates/src/main/java/package/service/dto/EntityCriteria.java.ejs b/generators/entity-server/templates/src/main/java/package/service/dto/EntityCriteria.java.ejs
index 9c30240e37..1b4fefb1e5 100644
--- a/generators/entity-server/templates/src/main/java/package/service/dto/EntityCriteria.java.ejs
+++ b/generators/entity-server/templates/src/main/java/package/service/dto/EntityCriteria.java.ejs
@@ -61,7 +61,7 @@ import io.github.jhipster.service.filter.ZonedDateTimeFilter;
   });
 _%>
 /**
- * Criteria class for the <%= entityClass %> entity. This class is used in <%= entityClass %>Resource to
+ * Criteria class for the <%= asEntity(entityClass) %> entity. This class is used in <%= entityClass %>Resource to
  * receive all the possible filtering options from the Http GET request parameters.
  * For example the following could be a valid requests:
  * <code> /<%= entityApiUrl %>?id.greaterThan=5&amp;attr1.contains=something&amp;attr2.specified=false</code>
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 6561211470..9229960669 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
@@ -55,7 +55,7 @@ import <%=packageName%>.domain.enumeration.<%= fields[idx].fieldType %>;
 /**
  * A DTO for the <%= entityClass %> entity.
  */
-public class <%= entityClass %>DTO implements Serializable {
+public class <%= asDto(entityClass) %> implements Serializable {
 
     private <%= pkType %> id;
     <%_ for (idx in fields) {
@@ -101,7 +101,7 @@ public class <%= entityClass %>DTO implements Serializable {
         const ownerSide = relationships[idx].ownerSide; _%>
     <%_ if (relationshipType === 'many-to-many' && ownerSide === true) { _%>
 
-    private Set<<%= otherEntityNameCapitalized %>DTO> <%= relationshipFieldNamePlural %> = new HashSet<>();
+    private Set<<%= asDto(otherEntityNameCapitalized) %>> <%= relationshipFieldNamePlural %> = new HashSet<>();
     <%_ } else if (relationshipType === 'many-to-one' || (relationshipType === 'one-to-one' && ownerSide === true)) { _%>
 
     private <% if (relationshipFieldName === 'user' && authenticationType === 'oauth2') { %>String<% } else { %><%= pkType %><% } %> <%= relationshipFieldName %>Id;
@@ -163,11 +163,11 @@ public class <%= entityClass %>DTO implements Serializable {
         ownerSide = relationships[idx].ownerSide;
         if (relationshipType === 'many-to-many' && ownerSide === true) { _%>
 
-    public Set<<%= otherEntityNameCapitalized %>DTO> get<%= relationshipNameCapitalizedPlural %>() {
+    public Set<<%= asDto(otherEntityNameCapitalized) %>> get<%= relationshipNameCapitalizedPlural %>() {
         return <%= relationshipFieldNamePlural %>;
     }
 
-    public void set<%= relationshipNameCapitalizedPlural %>(Set<<%= otherEntityNameCapitalized %>DTO> <%= otherEntityNamePlural %>) {
+    public void set<%= relationshipNameCapitalizedPlural %>(Set<<%= asDto(otherEntityNameCapitalized) %>> <%= otherEntityNamePlural %>) {
         this.<%= relationshipFieldNamePlural %> = <%= otherEntityNamePlural %>;
     }
     <%_ } else if (relationshipType === 'many-to-one' || (relationshipType === 'one-to-one' && ownerSide === true)) { _%>
@@ -209,11 +209,11 @@ public class <%= entityClass %>DTO implements Serializable {
             return false;
         }
 
-        <%= entityClass %>DTO <%= entityInstance %>DTO = (<%= entityClass %>DTO) o;
-        if (<%= entityInstance %>DTO.getId() == null || getId() == null) {
+        <%= asDto(entityClass) %> <%= asDto(entityInstance) %> = (<%= asDto(entityClass) %>) o;
+        if (<%= asDto(entityInstance) %>.getId() == null || getId() == null) {
             return false;
         }
-        return Objects.equals(getId(), <%= entityInstance %>DTO.getId());
+        return Objects.equals(getId(), <%= asDto(entityInstance) %>.getId());
     }
 
     @Override
@@ -223,7 +223,7 @@ public class <%= entityClass %>DTO implements Serializable {
 
     @Override
     public String toString() {
-        return "<%= entityClass %>DTO{" +
+        return "<%= asDto(entityClass) %>{" +
             "id=" + getId() +
             <%_ for (idx in fields) {
                 const fieldName = fields[idx].fieldName;
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 624b33d884..07be41a35d 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
@@ -19,8 +19,8 @@
 package <%= packageName %>.service<% if (service === 'serviceImpl') { %>.impl<% } %>;
 <%  const serviceClassName = service === 'serviceImpl' ? entityClass + 'ServiceImpl' : entityClass + 'Service';
     let viaService = false;
-    const instanceType = (dto === 'mapstruct') ? entityClass + 'DTO' : entityClass;
-    const instanceName = (dto === 'mapstruct') ? entityInstance + 'DTO' : entityInstance;
+    const instanceType = (dto === 'mapstruct') ? asDto(entityClass) : asEntity(entityClass);
+    const instanceName = (dto === 'mapstruct') ? asDto(entityInstance) : asEntity(entityInstance);
     const mapper = entityInstance  + 'Mapper';
     const dtoToEntity = mapper + '.'+ 'toEntity';
     const entityToDto = 'toDto';
@@ -29,7 +29,7 @@ package <%= packageName %>.service<% if (service === 'serviceImpl') { %>.impl<%
     const searchRepository = entityInstance  + 'SearchRepository';
     if (service === 'serviceImpl') { %>
 import <%= packageName %>.service.<%= entityClass %>Service;<% } %>
-import <%= packageName %>.domain.<%= entityClass %>;
+import <%= packageName %>.domain.<%= asEntity(entityClass) %>;
 import <%= packageName %>.repository.<%= entityClass %>Repository;
 <%_ if (reactiveRepositories) { _%>
 import <%= packageName %>.repository.reactive.<%= entityClass %>ReactiveRepository;
@@ -38,7 +38,7 @@ import <%= packageName %>.repository.reactive.<%= entityClass %>ReactiveReposito
 import <%= packageName %>.repository.search.<%= entityClass %>SearchRepository;
 <%_ } _%>
 <%_ if (dto === 'mapstruct') { _%>
-import <%= packageName %>.service.dto.<%= entityClass %>DTO;
+import <%= packageName %>.service.dto.<%= asDto(entityClass) %>;
 import <%= packageName %>.service.mapper.<%= entityClass %>Mapper;
 <%_ } _%>
 import org.slf4j.Logger;
@@ -78,14 +78,14 @@ import static org.elasticsearch.index.query.QueryBuilders.*;
 <%_ } _%>
 
 /**
- * Service Implementation for managing <%= entityClass %>.
+ * Service Implementation for managing <%= asEntity(entityClass) %>.
  */
 @Service<% if (databaseType === 'sql') { %>
 @Transactional<% } %>
 public class <%= serviceClassName %><% if (service === 'serviceImpl') { %> implements <%= entityClass %>Service<% } %> {
 
     private final Logger log = LoggerFactory.getLogger(<%= serviceClassName %>.class);
-<%- include('../../common/inject_template', {viaService: viaService, constructorName: serviceClassName, queryService: false}); -%>
+<%- include('../../common/inject_template', {asEntity, asDto, viaService, constructorName: serviceClassName, queryService: false}); -%>
 
     /**
      * Save a <%= entityInstance %>.
@@ -98,7 +98,7 @@ public class <%= serviceClassName %><% if (service === 'serviceImpl') { %> imple
     <%_ } _%>
     public <%= instanceType %> save(<%= instanceType %> <%= instanceName %>) {
         log.debug("Request to save <%= entityClass %> : {}", <%= instanceName %>);
-<%- include('../../common/save_template', {viaService: viaService, returnDirectly: true}); -%>
+<%- include('../../common/save_template', {asEntity, asDto, viaService, returnDirectly: true}); -%>
     }
 
     /**
@@ -147,7 +147,7 @@ public class <%= serviceClassName %><% if (service === 'serviceImpl') { %> imple
         return <%= entityInstance %>Repository.findAllWithEagerRelationships(pageable)<% if (dto !== 'mapstruct') { %>;<% } else { %>.map(<%= entityToDtoReference %>);<% } %>
     }
     <% } %>
-<%- include('../../common/get_filtered_template'); -%>
+<%- include('../../common/get_filtered_template', {asEntity, asDto}); -%>
     /**
      * Get one <%= entityInstance %> by id.
      *
@@ -161,7 +161,7 @@ public class <%= serviceClassName %><% if (service === 'serviceImpl') { %> imple
     @Transactional(readOnly = true)
     <%_ } _%>
     public Optional<<%= instanceType %>> findOne(<%= pkType %> id) {
-        log.debug("Request to get <%= entityClass %> : {}", id);<%- include('../../common/get_template', {viaService: viaService, returnDirectly:true}); -%>
+        log.debug("Request to get <%= entityClass %> : {}", id);<%- include('../../common/get_template', {asEntity, asDto, viaService, returnDirectly:true}); -%>
     }
 
     /**
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 766d8d95ea..2c715c2b49 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
@@ -19,21 +19,21 @@
 package <%=packageName%>.service.mapper;
 
 import <%=packageName%>.domain.*;
-import <%=packageName%>.service.dto.<%= entityClass %>DTO;
+import <%=packageName%>.service.dto.<%= asDto(entityClass) %>;
 
 import org.mapstruct.*;
 
 /**
- * Mapper for the entity <%= entityClass %> and its DTO <%= entityClass %>DTO.
+ * Mapper for the entity <%= asEntity(entityClass) %> and its DTO <%= asDto(entityClass) %>.
  */
 @Mapper(componentModel = "spring", uses = {<% var existingMappings = [];
   for (idx in relationships) {
     if ((relationships[idx].relationshipType === 'many-to-many' && relationships[idx].ownerSide === true)|| relationships[idx].relationshipType === 'many-to-one' ||(relationships[idx].relationshipType === 'one-to-one' && relationships[idx].ownerSide === true)){
       // if the entity is mapped twice, we should implement the mapping once
-      if (!existingMappings.includes(relationships[idx].otherEntityNameCapitalized) && relationships[idx].otherEntityNameCapitalized !== entityClass) {
+      if (!existingMappings.includes(relationships[idx].otherEntityNameCapitalized) && asEntity(relationships[idx].otherEntityNameCapitalized) !== asEntity(entityClass)) {
           existingMappings.push(relationships[idx].otherEntityNameCapitalized);
       } } } %><%= existingMappings.map(otherEntityNameCapitalized => otherEntityNameCapitalized + 'Mapper.class').join(', ') %>})
-public interface <%= entityClass %>Mapper extends EntityMapper<<%= entityClass %>DTO, <%= entityClass %>> {
+public interface <%= entityClass %>Mapper extends EntityMapper<<%= asDto(entityClass) %>, <%= asEntity(entityClass) %>> {
 
 <%_
 // entity -> DTO mapping
@@ -52,7 +52,7 @@ _%>
         <%_ } _%>
     <%_ } _%>
     <%_ if (renMapAnotEnt === true) { _%>
-    <%= entityClass %>DTO toDto(<%= entityClass %> <%= entityInstance %>);
+    <%= asDto(entityClass) %> toDto(<%= asEntity(entityClass) %> <%= asEntity(entityInstance) %>);
     <%_ } _%>
 
 <%_
@@ -78,17 +78,17 @@ _%>
             <%_ } _%>
         <%_ } _%>
     <%_ if (renMapAnotDto === true) { _%>
-    <%= entityClass %> toEntity(<%= entityClass%>DTO <%= entityInstance %>DTO);
+    <%= asEntity(entityClass) %> toEntity(<%= asDto(entityClass)%> <%= asDto(entityInstance) %>);
     <%_ } _%>
     <%_ if (databaseType === 'sql' || databaseType === 'mongodb') { _%>
 
-    default <%= entityClass %> fromId(<%= pkType %> id) {
+    default <%= asEntity(entityClass) %> fromId(<%= pkType %> id) {
         if (id == null) {
             return null;
         }
-        <%= entityClass %> <%= entityInstance %> = new <%= entityClass %>();
-        <%= entityInstance %>.setId(id);
-        return <%= entityInstance %>;
+        <%= asEntity(entityClass) %> <%= asEntity(entityInstance) %> = new <%= asEntity(entityClass) %>();
+        <%= asEntity(entityInstance) %>.setId(id);
+        return <%= asEntity(entityInstance) %>;
     }
 <%_ } _%>
 }
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 494d356290..7beef32ad5 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
@@ -19,7 +19,7 @@
 package <%=packageName%>.web.rest;
 
 <%_ if (dto !== 'mapstruct' || service === 'no') { _%>
-import <%=packageName%>.domain.<%= entityClass %>;
+import <%=packageName%>.domain.<%= asEntity(entityClass) %>;
 <%_ } _%>
 <%_ if (service !== 'no') { _%>
 import <%=packageName%>.service.<%= entityClass %>Service;
@@ -39,7 +39,7 @@ import <%=packageName%>.web.rest.errors.BadRequestAlertException;
 import <%=packageName%>.web.rest.util.HeaderUtil;<% if (pagination !== 'no') { %>
 import <%=packageName%>.web.rest.util.PaginationUtil;<% } %>
 <%_ if (dto === 'mapstruct') { _%>
-import <%=packageName%>.service.dto.<%= entityClass %>DTO;
+import <%=packageName%>.service.dto.<%= asDto(entityClass) %>;
 <%_ if (service === 'no') { _%>
 import <%=packageName%>.service.mapper.<%= entityClass %>Mapper;
 <%_ } } _%>
@@ -96,8 +96,8 @@ public class <%= entityClass %>Resource {
     } _%>
     private static final String ENTITY_NAME = "<%= entityName %>";
     <%_
-    const instanceType = (dto === 'mapstruct') ? entityClass + 'DTO' : entityClass;
-    const instanceName = (dto === 'mapstruct') ? entityInstance + 'DTO' : entityInstance;
+    const instanceType = (dto === 'mapstruct') ? asDto(entityClass) : asEntity(entityClass);
+    const instanceName = (dto === 'mapstruct') ? asDto(entityInstance) : asEntity(entityInstance);
     _%><%- include('../../common/inject_template', {viaService: viaService, constructorName: entityClass + 'Resource', queryService: jpaMetamodelFiltering}); -%>
 
     /**
@@ -122,7 +122,7 @@ public class <%= entityClass %>Resource {
         <%_ if (databaseType === 'cassandra') { _%>
         <%= instanceName %>.setId(UUID.randomUUID());
         <%_ } _%>
-<%- include('../../common/save_template', {viaService: viaService, returnDirectly: false}); -%>
+<%- include('../../common/save_template', {asEntity, asDto, viaService, returnDirectly: false}); -%>
         return ResponseEntity.created(new URI("/api/<%= entityApiUrl %>/" + result.getId()))
             .headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()))
             .body(result);
@@ -149,7 +149,7 @@ public class <%= entityClass %>Resource {
             userRepository.save(<%= instanceName %>.getUser());
         }
         <%_ } _%>
-<%- include('../../common/save_template', {viaService: viaService, returnDirectly: false}); -%>
+<%- include('../../common/save_template', {asEntity, asDto, viaService, returnDirectly: false}); -%>
         return ResponseEntity.ok()
             .headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, <%= instanceName %>.getId().toString()))
             .body(result);
@@ -164,7 +164,7 @@ public class <%= entityClass %>Resource {
      * @param filter the filter of the request<% } %>
      * @return the ResponseEntity with status 200 (OK) and the list of <%= entityInstancePlural %> in body
      */
-    @GetMapping("/<%= entityApiUrl %>")<%- include('../../common/get_all_template', {viaService: viaService}); -%>
+    @GetMapping("/<%= entityApiUrl %>")<%- include('../../common/get_all_template', {asEntity, asDto, viaService}); -%>
 
     <%_ if (reactiveRepositories) { _%>
     /**
@@ -190,7 +190,7 @@ public class <%= entityClass %>Resource {
      */
     @GetMapping("/<%= entityApiUrl %>/{id}")
     public ResponseEntity<<%= instanceType %>> get<%= entityClass %>(@PathVariable <%= pkType %> id) {
-        log.debug("REST request to get <%= entityClass %> : {}", id);<%- include('../../common/get_template', {viaService: viaService, returnDirectly:false}); -%>
+        log.debug("REST request to get <%= entityClass %> : {}", id);<%- include('../../common/get_template', {asEntity, asDto, viaService, returnDirectly:false}); -%>
         return ResponseUtil.wrapOrNotFound(<%= instanceName %>);
     }
 
@@ -215,5 +215,5 @@ public class <%= entityClass %>Resource {
      * @param pageable the pagination information<% } %>
      * @return the result of the search
      */
-    @GetMapping("/_search/<%= entityApiUrl %>")<%- include('../../common/search_template', {viaService: viaService}); -%><% } %>
+    @GetMapping("/_search/<%= entityApiUrl %>")<%- include('../../common/search_template', {asEntity, asDto, viaService}); -%><% } %>
 }
diff --git a/generators/entity/index.js b/generators/entity/index.js
index aad753b773..aeaadc76ee 100644
--- a/generators/entity/index.js
+++ b/generators/entity/index.js
@@ -217,6 +217,20 @@ module.exports = class extends BaseBlueprintGenerator {
                     this.log(chalk.green(`\nFound the ${context.filename} configuration file, entity can be automatically generated!\n`));
                     context.useConfigurationFile = true;
                 }
+
+                context.entitySuffix = configuration.get('entitySuffix');
+                if (_.isNil(context.entitySuffix)) {
+                    context.entitySuffix = '';
+                }
+
+                context.dtoSuffix = configuration.get('dtoSuffix');
+                if (_.isNil(context.dtoSuffix)) {
+                    context.dtoSuffix = 'DTO';
+                }
+
+                if (context.entitySuffix === context.dtoSuffix) {
+                    this.error(chalk.red('The entity cannot be generated as the entity suffix and DTO suffix are equals !'));
+                }
             },
 
             validateDbExistence() {
diff --git a/generators/generator-base-private.js b/generators/generator-base-private.js
index 4d5d2c7729..a913ed908d 100644
--- a/generators/generator-base-private.js
+++ b/generators/generator-base-private.js
@@ -915,16 +915,22 @@ module.exports = class extends Generator {
                 }
 
                 query = `this.${relationship.otherEntityName}Service
-            .query({${filter}})
-            .subscribe((res: HttpResponse<I${relationship.otherEntityAngularName}[]>) => {
+            .query({${filter}}).pipe(
+                filter((mayBeOk: HttpResponse<I${relationship.otherEntityAngularName}[]>) => mayBeOk.ok),
+                map((response: HttpResponse<I${relationship.otherEntityAngularName}[]>) => response.body),
+            )
+            .subscribe((res: I${relationship.otherEntityAngularName}[]) => {
                 if (${relationshipFieldNameIdCheck}) {
-                    this.${variableName} = res.body;
+                    this.${variableName} = res;
                 } else {
                     this.${relationship.otherEntityName}Service
-                        .find(${relationshipFieldName}${dto === 'no' ? '.id' : 'Id'})
-                        .subscribe((subRes: HttpResponse<I${relationship.otherEntityAngularName}>) => {
-                            this.${variableName} = [subRes.body].concat(res.body);
-                        }, (subRes: HttpErrorResponse) => this.onError(subRes.message));
+                        .find(${relationshipFieldName}${dto === 'no' ? '.id' : 'Id'}).pipe(
+                            filter((subResMayBeOk: HttpResponse<I${relationship.otherEntityAngularName}>) => subResMayBeOk.ok),
+                            map((subResponse: HttpResponse<I${relationship.otherEntityAngularName}>) => subResponse.body),
+                        )
+                        .subscribe((subRes: I${relationship.otherEntityAngularName}) => 
+                            this.${variableName} = [subRes].concat(res)
+                        , (subRes: HttpErrorResponse) => this.onError(subRes.message));
                 }
             }, (res: HttpErrorResponse) => this.onError(res.message));`;
             } else if (relationship.relationshipType !== 'one-to-many') {
@@ -932,10 +938,13 @@ module.exports = class extends Generator {
                 if (variableName === entityInstance) {
                     variableName += 'Collection';
                 }
-                query = `this.${relationship.otherEntityName}Service.query()
-            .subscribe((res: HttpResponse<I${
-                relationship.otherEntityAngularName
-            }[]>) => { this.${variableName} = res.body; }, (res: HttpErrorResponse) => this.onError(res.message));`;
+                query = `this.${relationship.otherEntityName}Service.query().pipe(
+                            filter((mayBeOk: HttpResponse<I${relationship.otherEntityAngularName}[]>) => mayBeOk.ok),
+                            map((response: HttpResponse<I${relationship.otherEntityAngularName}[]>) => response.body),
+                        )
+            .subscribe(
+                (res: I${relationship.otherEntityAngularName}[]) => this.${variableName} = res, 
+                (res: HttpErrorResponse) => this.onError(res.message));`;
             }
             if (variableName && !this.contains(queries, query)) {
                 queries.push(query);
diff --git a/generators/generator-base.js b/generators/generator-base.js
index a6cef217ab..88864f5d4f 100644
--- a/generators/generator-base.js
+++ b/generators/generator-base.js
@@ -2923,4 +2923,20 @@ module.exports = class extends PrivateBase {
     fetchFromInstalledJHipster(subpath) {
         return path.join(__dirname, subpath);
     }
+
+    /**
+     * Construct the entity name by appending the entity suffix.
+     * @param {String} name entity name
+     */
+    asEntity(name) {
+        return name + this.entitySuffix;
+    }
+
+    /**
+     * Construct the entity's dto name by appending the dto suffix.
+     * @param {String} name entity name
+     */
+    asDto(name) {
+        return name + this.dtoSuffix;
+    }
 };
diff --git a/generators/server/files.js b/generators/server/files.js
index e523e8d24f..bd6c56597c 100644
--- a/generators/server/files.js
+++ b/generators/server/files.js
@@ -1352,14 +1352,20 @@ const serverFiles = {
             condition: generator => generator.skipUserManagement && generator.authenticationType === 'oauth2',
             path: SERVER_MAIN_SRC_DIR,
             templates: [
-                { file: 'package/domain/User.java', renameTo: generator => `${generator.javaDir}domain/User.java` },
+                {
+                    file: 'package/domain/User.java',
+                    renameTo: generator => `${generator.javaDir}domain/${generator.asEntity('User')}.java`
+                },
                 { file: 'package/domain/Authority.java', renameTo: generator => `${generator.javaDir}domain/Authority.java` },
                 { file: 'package/service/UserService.java', renameTo: generator => `${generator.javaDir}service/UserService.java` },
                 {
                     file: 'package/service/dto/package-info.java',
                     renameTo: generator => `${generator.javaDir}service/dto/package-info.java`
                 },
-                { file: 'package/service/dto/UserDTO.java', renameTo: generator => `${generator.javaDir}service/dto/UserDTO.java` },
+                {
+                    file: 'package/service/dto/UserDTO.java',
+                    renameTo: generator => `${generator.javaDir}service/dto/${generator.asDto('User')}.java`
+                },
                 {
                     file: 'package/service/mapper/package-info.java',
                     renameTo: generator => `${generator.javaDir}service/mapper/package-info.java`
@@ -1530,7 +1536,10 @@ const serverFiles = {
             path: SERVER_MAIN_SRC_DIR,
             templates: [
                 /* User management java domain files */
-                { file: 'package/domain/User.java', renameTo: generator => `${generator.javaDir}domain/User.java` },
+                {
+                    file: 'package/domain/User.java',
+                    renameTo: generator => `${generator.javaDir}domain/${generator.asEntity('User')}.java`
+                },
                 {
                     file: 'package/repository/UserRepository.java',
                     renameTo: generator => `${generator.javaDir}repository/${generator.reactiveRepository}UserRepository.java`
@@ -1545,7 +1554,10 @@ const serverFiles = {
                     file: 'package/service/dto/package-info.java',
                     renameTo: generator => `${generator.javaDir}service/dto/package-info.java`
                 },
-                { file: 'package/service/dto/UserDTO.java', renameTo: generator => `${generator.javaDir}service/dto/UserDTO.java` },
+                {
+                    file: 'package/service/dto/UserDTO.java',
+                    renameTo: generator => `${generator.javaDir}service/dto/${generator.asDto('User')}.java`
+                },
                 {
                     file: 'package/service/dto/PasswordChangeDTO.java',
                     renameTo: generator => `${generator.javaDir}service/dto/PasswordChangeDTO.java`
diff --git a/generators/server/index.js b/generators/server/index.js
index 9e82328cdc..66aea9a281 100644
--- a/generators/server/index.js
+++ b/generators/server/index.js
@@ -229,6 +229,20 @@ module.exports = class extends BaseBlueprintGenerator {
                     this.websocket = false;
                 }
 
+                this.entitySuffix = configuration.get('entitySuffix');
+                if (_.isNil(this.entitySuffix)) {
+                    this.entitySuffix = '';
+                }
+
+                this.dtoSuffix = configuration.get('dtoSuffix');
+                if (_.isNil(this.dtoSuffix)) {
+                    this.dtoSuffix = 'DTO';
+                }
+
+                if (this.entitySuffix === this.dtoSuffix) {
+                    this.error(chalk.red('Entities cannot be generated as the entity suffix and DTO suffix are equals !'));
+                }
+
                 const serverConfigFound =
                     this.packageName !== undefined &&
                     this.authenticationType !== undefined &&
diff --git a/generators/server/templates/gradle/sonar.gradle.ejs b/generators/server/templates/gradle/sonar.gradle.ejs
index b4e95af335..b26068f16d 100644
--- a/generators/server/templates/gradle/sonar.gradle.ejs
+++ b/generators/server/templates/gradle/sonar.gradle.ejs
@@ -59,12 +59,9 @@ sonarqube {
 
         property "sonar.jacoco.reportPaths", "${project.buildDir}/jacoco/test.exec"
         property "sonar.java.codeCoveragePlugin", "jacoco"
-        <%_ if (!skipClient) { _%>
-        property "sonar.testExecutionReportPaths", "${project.buildDir}/test-results/jest/TESTS-results-sonar.xml"
-        <%_ } _%>
         property "sonar.typescript.lcov.reportPaths", "${project.buildDir}/test-results/lcov.info"
-        property "sonar.junit.reportPaths", "${project.buildDir}/test-results/test"
+        property "sonar.junit.reportPaths", "${project.buildDir}/test-results"
         property "sonar.sources", "${project.projectDir}/<%= MAIN_DIR %>"
         property "sonar.tests", "${project.projectDir}/<%= TEST_DIR %>"
     }
-}
\ No newline at end of file
+}
diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs
index f8bc3d4368..1b2d47b990 100644
--- a/generators/server/templates/pom.xml.ejs
+++ b/generators/server/templates/pom.xml.ejs
@@ -140,11 +140,10 @@
         <sonar.jacoco.reportPaths>${project.testresult.directory}/coverage/jacoco/jacoco.exec</sonar.jacoco.reportPaths>
         <sonar.java.codeCoveragePlugin>jacoco</sonar.java.codeCoveragePlugin>
         <%_ if (!skipClient) { _%>
-        <sonar.testExecutionReportPaths>${project.testresult.directory}/jest/TESTS-results-sonar.xml</sonar.testExecutionReportPaths>
         <sonar.typescript.lcov.reportPaths>${project.testresult.directory}/lcov.info</sonar.typescript.lcov.reportPaths>
         <%_ } _%>
         <sonar.sources>${project.basedir}/<%= MAIN_DIR %></sonar.sources>
-        <sonar.surefire.reportsPath>${project.testresult.directory}/surefire-reports</sonar.surefire.reportsPath>
+        <sonar.junit.reportsPath>${project.testresult.directory}</sonar.junit.reportsPath>
         <sonar.tests>${project.basedir}/<%= TEST_DIR %></sonar.tests>
 
         <!-- jhipster-needle-maven-property -->
@@ -844,21 +843,21 @@
                     <groupId>pl.project13.maven</groupId>
                     <artifactId>git-commit-id-plugin</artifactId>
                     <version>${git-commit-id-plugin.version}</version>
-                        <executions>
-                            <execution>
-                                <goals>
-                                    <goal>revision</goal>
-                                </goals>
-                            </execution>
-                        </executions>
-                        <configuration>
-                            <failOnNoGitDirectory>false</failOnNoGitDirectory>
-                            <generateGitPropertiesFile>true</generateGitPropertiesFile>
-                            <includeOnlyProperties>
-                                <includeOnlyProperty>^git.commit.id.abbrev$</includeOnlyProperty>
-                                <includeOnlyProperty>^git.commit.id.describe$</includeOnlyProperty>
-                                <includeOnlyProperty>^git.branch$</includeOnlyProperty>
-                            </includeOnlyProperties>
+                    <executions>
+                        <execution>
+                            <goals>
+                                <goal>revision</goal>
+                            </goals>
+                        </execution>
+                    </executions>
+                    <configuration>
+                        <failOnNoGitDirectory>false</failOnNoGitDirectory>
+                        <generateGitPropertiesFile>true</generateGitPropertiesFile>
+                        <includeOnlyProperties>
+                            <includeOnlyProperty>^git.commit.id.abbrev$</includeOnlyProperty>
+                            <includeOnlyProperty>^git.commit.id.describe$</includeOnlyProperty>
+                            <includeOnlyProperty>^git.branch$</includeOnlyProperty>
+                        </includeOnlyProperties>
                     </configuration>
                 </plugin>
                 <plugin>
@@ -928,10 +927,10 @@
                     <artifactId>liquibase-maven-plugin</artifactId>
                     <version>${liquibase.version}</version>
                     <configuration>
-                        <changeLogFile><%= SERVER_MAIN_RES_DIR %>config/liquibase/master.xml</changeLogFile>
-                        <diffChangeLogFile><%= SERVER_MAIN_RES_DIR %>config/liquibase/changelog/${maven.build.timestamp}_changelog.xml</diffChangeLogFile>
+                        <changeLogFile>${project.basedir}/<%= SERVER_MAIN_RES_DIR %>config/liquibase/master.xml</changeLogFile>
+                        <diffChangeLogFile>${project.basedir}/<%= SERVER_MAIN_RES_DIR %>config/liquibase/changelog/${maven.build.timestamp}_changelog.xml</diffChangeLogFile>
                         <driver><% if (devDatabaseType === 'mysql') { %>com.mysql.jdbc.Driver<% } else if (devDatabaseType === 'mariadb') { %>org.mariadb.jdbc.Driver<% } else if (devDatabaseType === 'postgresql') { %>org.postgresql.Driver<% } else if (devDatabaseType === 'h2Disk') { %>org.h2.Driver<% } else if (devDatabaseType === 'oracle') { %>oracle.jdbc.OracleDriver<% } %></driver>
-                        <url><% if (devDatabaseType === 'mysql') { %>jdbc:mysql://localhost:3306/<%= baseName %><% } else if (devDatabaseType === 'mariadb') { %>jdbc:mariadb://localhost:3306/<%= baseName %><% } else if (devDatabaseType === 'postgresql') { %>jdbc:postgresql://localhost:5432/<%= baseName %><% } else if (devDatabaseType === 'h2Disk') { %>jdbc:h2:file:./target/h2db/db/<%= lowercaseBaseName %><% } else if (devDatabaseType === 'oracle') { %>jdbc:oracle:thin:@localhost:1521:<%= baseName %><% } else if (devDatabaseType === 'mssql') { %>jdbc:sqlserver://localhost:1433;database=<%= baseName %><% } %></url>
+                        <url><% if (devDatabaseType === 'mysql') { %>jdbc:mysql://localhost:3306/<%= baseName %><% } else if (devDatabaseType === 'mariadb') { %>jdbc:mariadb://localhost:3306/<%= baseName %><% } else if (devDatabaseType === 'postgresql') { %>jdbc:postgresql://localhost:5432/<%= baseName %><% } else if (devDatabaseType === 'h2Disk') { %>jdbc:h2:file:${project.build.directory}/h2db/db/<%= lowercaseBaseName %><% } else if (devDatabaseType === 'oracle') { %>jdbc:oracle:thin:@localhost:1521:<%= baseName %><% } else if (devDatabaseType === 'mssql') { %>jdbc:sqlserver://localhost:1433;database=<%= baseName %><% } %></url>
                         <defaultSchemaName><% if (devDatabaseType === 'mysql') { %><%= baseName %><% } else if (devDatabaseType === 'postgresql') { %><% } %></defaultSchemaName>
                         <username><% if (devDatabaseType === 'mysql') { %>root<% } else if (devDatabaseType === 'postgresql' || devDatabaseType === 'h2Disk' || devDatabaseType === 'h2Memory') { %><%= baseName %><% } else if (devDatabaseType === 'mssql') { %>SA<% } %></username>
                         <password><% if (devDatabaseType === 'mssql') { %>yourStrong(!)Password<% } %></password>
@@ -1019,7 +1018,7 @@
                                 <goal>copy-resources</goal>
                             </goals>
                             <configuration>
-                                <outputDirectory>target/classes</outputDirectory>
+                                <outputDirectory>${project.build.directory}/classes</outputDirectory>
                                 <useDefaultDelimiters>false</useDefaultDelimiters>
                                 <delimiters>
                                     <delimiter>#</delimiter>
@@ -1049,10 +1048,10 @@
                                 <goal>copy-resources</goal>
                             </goals>
                             <configuration>
-                                <outputDirectory>target/classes/static/</outputDirectory>
+                                <outputDirectory>${project.build.directory}/classes/static/</outputDirectory>
                                 <resources>
                                     <resource>
-                                        <directory>target/www</directory>
+                                        <directory>${project.build.directory}/www</directory>
                                         <filtering>false</filtering>
                                     </resource>
                                 </resources>
@@ -1094,6 +1093,7 @@
                         <!-- Fixes a bug which will be solved in next version after 2.22.1 then this can be removed -->
                         <!-- see: https://issues.apache.org/jira/browse/SUREFIRE-1588 -->
                         <useSystemClassLoader>false</useSystemClassLoader>
+                        <outputDirectory>${sonar.junit.reportsPath}</outputDirectory>
                     </configuration>
                 </plugin>
                 <plugin>
@@ -1200,7 +1200,7 @@
             <id>webpack</id>
             <activation>
                 <file>
-                    <missing>${basedir}/target/www/app/main.bundle.js</missing>
+                    <missing>${project.build.directory}/www/app/main.bundle.js</missing>
                 </file>
             </activation>
             <dependencies>
diff --git a/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs b/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs
index b33eb05e45..652a03ace5 100644
--- a/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs
+++ b/generators/server/templates/src/main/java/package/config/CacheConfiguration.java.ejs
@@ -164,12 +164,12 @@ public class CacheConfiguration {
             cm.createCache(<%=packageName%>.repository<% if (reactive) { %>.reactive<% } %>.UserRepository.USERS_BY_LOGIN_CACHE, jcacheConfiguration);
             cm.createCache(<%=packageName%>.repository<% if (reactive) { %>.reactive<% } %>.UserRepository.USERS_BY_EMAIL_CACHE, jcacheConfiguration);
                 <%_ if (enableHibernateCache) { _%>
-            cm.createCache(<%=packageName%>.domain.User.class.getName(), jcacheConfiguration);
+            cm.createCache(<%=packageName%>.domain.<%= asEntity('User') %>.class.getName(), jcacheConfiguration);
             cm.createCache(<%=packageName%>.domain.Authority.class.getName(), jcacheConfiguration);
-            cm.createCache(<%=packageName%>.domain.User.class.getName() + ".authorities", jcacheConfiguration);
+            cm.createCache(<%=packageName%>.domain.<%= asEntity('User') %>.class.getName() + ".authorities", jcacheConfiguration);
                     <%_ if (authenticationType === 'session') { _%>
             cm.createCache(<%=packageName%>.domain.PersistentToken.class.getName(), jcacheConfiguration);
-            cm.createCache(<%=packageName%>.domain.User.class.getName() + ".persistentTokens", jcacheConfiguration);
+            cm.createCache(<%=packageName%>.domain.<%= asEntity('User') %>.class.getName() + ".persistentTokens", jcacheConfiguration);
                     <%_ } _%>
                 <%_ } _%>
             <%_ } _%>
@@ -215,8 +215,7 @@ public class CacheConfiguration {
     @Bean
     public CacheManager cacheManager(HazelcastInstance hazelcastInstance) {
         log.debug("Starting HazelcastCacheManager");
-        CacheManager cacheManager = new com.hazelcast.spring.cache.HazelcastCacheManager(hazelcastInstance);
-        return cacheManager;
+        return new com.hazelcast.spring.cache.HazelcastCacheManager(hazelcastInstance);
     }
 
     @Bean
@@ -248,7 +247,7 @@ public class CacheConfiguration {
                 config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(true);
                 for (ServiceInstance instance : discoveryClient.getInstances(serviceId)) {
                     String clusterMember = "127.0.0.1:" + (instance.getPort() + 5701);
-                    log.debug("Adding Hazelcast (dev) cluster member " + clusterMember);
+                    log.debug("Adding Hazelcast (dev) cluster member {}", clusterMember);
                     config.getNetworkConfig().getJoin().getTcpIpConfig().addMember(clusterMember);
                 }
             } else { // Production configuration, one host per instance all using port 5701
@@ -256,7 +255,7 @@ public class CacheConfiguration {
                 config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(true);
                 for (ServiceInstance instance : discoveryClient.getInstances(serviceId)) {
                     String clusterMember = instance.getHost() + ":5701";
-                    log.debug("Adding Hazelcast (prod) cluster member " + clusterMember);
+                    log.debug("Adding Hazelcast (prod) cluster member {}", clusterMember);
                     config.getNetworkConfig().getJoin().getTcpIpConfig().addMember(clusterMember);
                 }
             }
@@ -521,21 +520,21 @@ public class CacheConfiguration {
                 cacheManager.getCache(<%=packageName%>.repository.UserRepository.USERS_BY_EMAIL_CACHE).getAdvancedCache(), this,
                 ConfigurationAdapter.create()));
                 <%_ if (enableHibernateCache) { _%>
-            registerPredefinedCache(<%=packageName%>.domain.User.class.getName(), new JCache<Object, Object>(
-                cacheManager.getCache(<%=packageName%>.domain.User.class.getName()).getAdvancedCache(), this,
+            registerPredefinedCache(<%=packageName%>.domain.<%= asEntity('User') %>.class.getName(), new JCache<Object, Object>(
+                cacheManager.getCache(<%=packageName%>.domain.<%= asEntity('User') %>.class.getName()).getAdvancedCache(), this,
                 ConfigurationAdapter.create()));
             registerPredefinedCache(<%=packageName%>.domain.Authority.class.getName(), new JCache<Object, Object>(
                 cacheManager.getCache(<%=packageName%>.domain.Authority.class.getName()).getAdvancedCache(), this,
                 ConfigurationAdapter.create()));
-            registerPredefinedCache(<%=packageName%>.domain.User.class.getName() + ".authorities", new JCache<Object, Object>(
-                cacheManager.getCache(<%=packageName%>.domain.User.class.getName() + ".authorities").getAdvancedCache(), this,
+            registerPredefinedCache(<%=packageName%>.domain.<%= asEntity('User') %>.class.getName() + ".authorities", new JCache<Object, Object>(
+                cacheManager.getCache(<%=packageName%>.domain.<%= asEntity('User') %>.class.getName() + ".authorities").getAdvancedCache(), this,
                 ConfigurationAdapter.create()));
                     <%_ if (authenticationType === 'session') { _%>
             registerPredefinedCache(<%=packageName%>.domain.PersistentToken.class.getName(), new JCache<Object, Object>(
                 cacheManager.getCache(<%=packageName%>.domain.PersistentToken.class.getName()).getAdvancedCache(), this,
                 ConfigurationAdapter.create()));
-            registerPredefinedCache(<%=packageName%>.domain.User.class.getName() + ".persistentTokens", new JCache<Object, Object>(
-                cacheManager.getCache(<%=packageName%>.domain.User.class.getName() + ".persistentTokens").getAdvancedCache(), this,
+            registerPredefinedCache(<%=packageName%>.domain.<%= asEntity('User') %>.class.getName() + ".persistentTokens", new JCache<Object, Object>(
+                cacheManager.getCache(<%=packageName%>.domain.<%= asEntity('User') %>.class.getName() + ".persistentTokens").getAdvancedCache(), this,
                 ConfigurationAdapter.create()));
                     <%_ } _%>
                 <%_ } _%>
@@ -563,7 +562,7 @@ public class CacheConfiguration {
         try {
             for (ServiceInstance instance : discoveryClient.getInstances(registration.getServiceId())) {
                 String clusterMember = instance.getHost() + ":7800";
-                log.debug("Adding Infinispan cluster member " + clusterMember);
+                log.debug("Adding Infinispan cluster member {}", clusterMember);
                 initialHosts.add(new IpAddress(clusterMember));
             }
             TCP tcp = new TCP();
diff --git a/generators/server/templates/src/main/java/package/config/CloudDatabaseConfiguration.java.ejs b/generators/server/templates/src/main/java/package/config/CloudDatabaseConfiguration.java.ejs
index 43013fc22b..1c1b09c434 100644
--- a/generators/server/templates/src/main/java/package/config/CloudDatabaseConfiguration.java.ejs
+++ b/generators/server/templates/src/main/java/package/config/CloudDatabaseConfiguration.java.ejs
@@ -78,7 +78,7 @@ public class CloudDatabaseConfiguration extends AbstractCloudConfig {
     <%_ } _%>
     <%_ if (databaseType === 'sql') { _%>
     
-    private final String CLOUD_CONFIGURATION_HIKARI_PREFIX = "spring.datasource.hikari";
+    private static final String CLOUD_CONFIGURATION_HIKARI_PREFIX = "spring.datasource.hikari";
 
     @Bean
     @ConfigurationProperties(CLOUD_CONFIGURATION_HIKARI_PREFIX)
diff --git a/generators/server/templates/src/main/java/package/config/DatabaseConfiguration.java.ejs b/generators/server/templates/src/main/java/package/config/DatabaseConfiguration.java.ejs
index e7e7d7dd1c..df9b68ae36 100644
--- a/generators/server/templates/src/main/java/package/config/DatabaseConfiguration.java.ejs
+++ b/generators/server/templates/src/main/java/package/config/DatabaseConfiguration.java.ejs
@@ -100,7 +100,6 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
 
 <%_ if (devDatabaseType === 'h2Disk' || devDatabaseType === 'h2Memory') { _%>
 import java.sql.SQLException;
-import java.lang.NumberFormatException;
 <%_ } } _%>
 <%_ if (databaseType === 'mongodb') { _%>
 import java.util.ArrayList;
@@ -180,7 +179,7 @@ public class DatabaseConfiguration {
         return H2ConfigurationHelper.createServer(port);
     }
 	
-    private String getValidPortForH2() throws NumberFormatException {
+    private String getValidPortForH2() {
         int port = Integer.parseInt(env.getProperty("server.port"));
         if (port < 10000) {
             port = 10000 + port;
diff --git a/generators/server/templates/src/main/java/package/config/dbmigrations/InitialSetupMigration.java.ejs b/generators/server/templates/src/main/java/package/config/dbmigrations/InitialSetupMigration.java.ejs
index 59b00153ce..cc703c63f2 100644
--- a/generators/server/templates/src/main/java/package/config/dbmigrations/InitialSetupMigration.java.ejs
+++ b/generators/server/templates/src/main/java/package/config/dbmigrations/InitialSetupMigration.java.ejs
@@ -19,7 +19,7 @@
 package <%=packageName%>.config.dbmigrations;
 
 import <%=packageName%>.domain.Authority;
-import <%=packageName%>.domain.User;
+import <%=packageName%>.domain.<%= asEntity('User') %>;
 import <%=packageName%>.security.AuthoritiesConstants;
 
 import com.github.mongobee.changeset.ChangeLog;
@@ -52,7 +52,7 @@ public class InitialSetupMigration {
         Authority userAuthority = new Authority();
         userAuthority.setName(AuthoritiesConstants.USER);
 
-        User systemUser = new User();
+        <%= asEntity('User') %> systemUser = new <%= asEntity('User') %>();
         systemUser.setId("user-0");
         systemUser.setLogin("system");
         <%_ if (authenticationType !== 'oauth2') { _%>
@@ -69,7 +69,7 @@ public class InitialSetupMigration {
         systemUser.getAuthorities().add(userAuthority);
         mongoTemplate.save(systemUser);
 
-        User anonymousUser = new User();
+        <%= asEntity('User') %> anonymousUser = new <%= asEntity('User') %>();
         anonymousUser.setId("user-1");
         anonymousUser.setLogin("anonymoususer");
         <%_ if (authenticationType !== 'oauth2') { _%>
@@ -84,7 +84,7 @@ public class InitialSetupMigration {
         anonymousUser.setCreatedDate(Instant.now());
         mongoTemplate.save(anonymousUser);
 
-        User adminUser = new User();
+        <%= asEntity('User') %> adminUser = new <%= asEntity('User') %>();
         adminUser.setId("user-2");
         adminUser.setLogin("admin");
         <%_ if (authenticationType !== 'oauth2') { _%>
@@ -101,7 +101,7 @@ public class InitialSetupMigration {
         adminUser.getAuthorities().add(userAuthority);
         mongoTemplate.save(adminUser);
 
-        User userUser = new User();
+        <%= asEntity('User') %> userUser = new <%= asEntity('User') %>();
         userUser.setId("user-3");
         userUser.setLogin("user");
         <%_ if (authenticationType !== 'oauth2') { _%>
diff --git a/generators/server/templates/src/main/java/package/domain/PersistentToken.java.ejs b/generators/server/templates/src/main/java/package/domain/PersistentToken.java.ejs
index 0ae0241810..3255819554 100644
--- a/generators/server/templates/src/main/java/package/domain/PersistentToken.java.ejs
+++ b/generators/server/templates/src/main/java/package/domain/PersistentToken.java.ejs
@@ -147,7 +147,7 @@ public class PersistentToken implements Serializable {
         <%_ if (databaseType === 'mongodb') { _%>
     @DBRef
         <%_ } _%>
-    private User user;
+    private <%= asEntity('User') %> user;
     <%_ } _%>
 
     public String getSeries() {
@@ -194,11 +194,11 @@ public class PersistentToken implements Serializable {
         }
     }<% if (databaseType === 'sql' || databaseType === 'mongodb')  { %>
 
-    public User getUser() {
+    public <%= asEntity('User') %> getUser() {
         return user;
     }
 
-    public void setUser(User user) {
+    public void setUser(<%= asEntity('User') %> user) {
         this.user = user;
     }<% } %><% if (databaseType === 'cassandra' || databaseType === 'couchbase') { %>
 
diff --git a/generators/server/templates/src/main/java/package/domain/User.java.ejs b/generators/server/templates/src/main/java/package/domain/User.java.ejs
index 6cea285c39..7bb41d2395 100644
--- a/generators/server/templates/src/main/java/package/domain/User.java.ejs
+++ b/generators/server/templates/src/main/java/package/domain/User.java.ejs
@@ -73,7 +73,7 @@ import static org.springframework.data.couchbase.core.mapping.id.GenerationStrat
 @Document<% } %><% if (databaseType === 'cassandra') { %>
 @Table(name = "user")<% } %><% if (searchEngine === 'elasticsearch') { %>
 @org.springframework.data.elasticsearch.annotations.Document(indexName = "user")<% } %>
-public class User<% if (databaseType === 'sql' || databaseType === 'mongodb' || databaseType === 'couchbase') { %> extends AbstractAuditingEntity<% } %> implements Serializable {
+public class <%= asEntity('User') %><% if (databaseType === 'sql' || databaseType === 'mongodb' || databaseType === 'couchbase') { %> extends AbstractAuditingEntity<% } %> implements Serializable {
 
     private static final long serialVersionUID = 1L;
 <% if (databaseType === 'sql') { %>
@@ -320,7 +320,7 @@ public class User<% if (databaseType === 'sql' || databaseType === 'mongodb' ||
             return false;
         }
 
-        User user = (User) o;
+        <%= asEntity('User') %> user = (<%= asEntity('User') %>) o;
         return !(user.getId() == null || getId() == null) && Objects.equals(getId(), user.getId());
     }
 
@@ -331,7 +331,7 @@ public class User<% if (databaseType === 'sql' || databaseType === 'mongodb' ||
 
     @Override
     public String toString() {
-        return "User{" +
+        return "<%= asEntity('User') %>{" +
             "login='" + login + '\'' +
             ", firstName='" + firstName + '\'' +
             ", lastName='" + lastName + '\'' +
diff --git a/generators/server/templates/src/main/java/package/repository/PersistentTokenRepository.java.ejs b/generators/server/templates/src/main/java/package/repository/PersistentTokenRepository.java.ejs
index 76adfeebb3..5f71543689 100644
--- a/generators/server/templates/src/main/java/package/repository/PersistentTokenRepository.java.ejs
+++ b/generators/server/templates/src/main/java/package/repository/PersistentTokenRepository.java.ejs
@@ -22,7 +22,7 @@ import com.datastax.driver.core.*;
 import com.datastax.driver.mapping.Mapper;
 import com.datastax.driver.mapping.MappingManager;<% } %>
 import <%=packageName%>.domain.PersistentToken;
-import <%=packageName%>.domain.User;<% if (databaseType !== 'cassandra') { %>
+import <%=packageName%>.domain.<%= asEntity('User') %>;<% if (databaseType !== 'cassandra') { %>
 import java.time.LocalDate;<% } %><% if (databaseType === 'sql') { %>
 import org.springframework.data.jpa.repository.JpaRepository;
 <% } %><% if (databaseType === 'mongodb') { %>
@@ -62,12 +62,12 @@ public interface PersistentTokenRepository extends <% if (databaseType === 'sql'
         delete(PersistentToken.PREFIX + ID_DELIMITER + series);
     }
 
-    default List<PersistentToken> findByUser(User user) {
+    default List<PersistentToken> findByUser(<%= asEntity('User') %> user) {
         return findByLogin(user.getLogin());
     }
 
     List<PersistentToken> findByLogin(String login);<% } else { %>
-    List<PersistentToken> findByUser(User user);<% } %>
+    List<PersistentToken> findByUser(<%= asEntity('User') %> user);<% } %>
 
     List<PersistentToken> findByTokenDateBefore(LocalDate localDate);
 
@@ -118,7 +118,7 @@ public class PersistentTokenRepository {
         return Optional.ofNullable(mapper.get(presentedSeries));
     }
 
-    public List<PersistentToken> findByUser(User user) {
+    public List<PersistentToken> findByUser(<%= asEntity('User') %> user) {
         BoundStatement stmt = findPersistentTokenSeriesByUserIdStmt.bind();
         stmt.setString("user_id", user.getId());
         ResultSet rs = session.execute(stmt);
diff --git a/generators/server/templates/src/main/java/package/repository/UserRepository.java.ejs b/generators/server/templates/src/main/java/package/repository/UserRepository.java.ejs
index 38523a551c..dc95cbde20 100644
--- a/generators/server/templates/src/main/java/package/repository/UserRepository.java.ejs
+++ b/generators/server/templates/src/main/java/package/repository/UserRepository.java.ejs
@@ -24,7 +24,7 @@ import com.datastax.driver.mapping.Mapper;
 import com.datastax.driver.mapping.MappingManager;
 <%_ } _%>
 
-import <%=packageName%>.domain.User;
+import <%=packageName%>.domain.<%= asEntity('User') %>;
 
 <%_ if (cacheManagerIsAvailable === true) { _%>
 import org.springframework.cache.annotation.Cacheable;
@@ -87,7 +87,7 @@ import static <%=packageName%>.config.Constants.ID_DELIMITER;
 <%_ } _%>
 <%_ if (databaseType === 'sql' || databaseType === 'mongodb' || databaseType === 'couchbase') { _%>
 @Repository
-public interface UserRepository extends <% if (databaseType === 'sql') { %>JpaRepository<User, <% if (authenticationType === 'oauth2') { %>String<% } else { %>Long<% } %>><% } %><% if (reactive) { %>Reactive<% } %><% if (databaseType === 'mongodb') { %>MongoRepository<User, String><% } %><% if (databaseType === 'couchbase') { %>N1qlCouchbaseRepository<User, String><% } %> {
+public interface UserRepository extends <% if (databaseType === 'sql') { %>JpaRepository<<%= asEntity('User') %>, <% if (authenticationType === 'oauth2') { %>String<% } else { %>Long<% } %>><% } %><% if (reactive) { %>Reactive<% } %><% if (databaseType === 'mongodb') { %>MongoRepository<<%= asEntity('User') %>, String><% } %><% if (databaseType === 'couchbase') { %>N1qlCouchbaseRepository<<%= asEntity('User') %>, String><% } %> {
     <%_ if (cacheManagerIsAvailable === true) { _%>
 
     String USERS_BY_LOGIN_CACHE = "usersByLogin";
@@ -96,13 +96,13 @@ public interface UserRepository extends <% if (databaseType === 'sql') { %>JpaRe
     <%_ } _%>
     <%_ if (authenticationType !== 'oauth2') { _%>
 
-    <% if (reactive) { %>Mono<% } else { %>Optional<% } %><User> findOneByActivationKey(String activationKey);
+    <% if (reactive) { %>Mono<% } else { %>Optional<% } %><<%= asEntity('User') %>> findOneByActivationKey(String activationKey);
     <%_ } _%>
 
-    <% if (reactive) { %>Flux<% } else { %>List<% } %><User> findAllByActivatedIsFalseAndCreatedDateBefore(Instant dateTime);
+    <% if (reactive) { %>Flux<% } else { %>List<% } %><<%= asEntity('User') %>> findAllByActivatedIsFalseAndCreatedDateBefore(Instant dateTime);
     <%_ if (authenticationType !== 'oauth2') { _%>
 
-    <% if (reactive) { %>Mono<% } else { %>Optional<% } %><User> findOneByResetKey(String resetKey);
+    <% if (reactive) { %>Mono<% } else { %>Optional<% } %><<%= asEntity('User') %>> findOneByResetKey(String resetKey);
     <%_ } _%>
 
     <%_ if (databaseType === 'couchbase' || databaseType === 'mongodb') { _%>
@@ -110,42 +110,42 @@ public interface UserRepository extends <% if (databaseType === 'sql') { %>JpaRe
     @Cacheable(cacheNames = USERS_BY_EMAIL_CACHE)
         <%_ } _%>
     <%_ } _%>
-    <% if (reactive) { %>Mono<% } else { %>Optional<% } %><User> findOneByEmailIgnoreCase(String email);
+    <% if (reactive) { %>Mono<% } else { %>Optional<% } %><<%= asEntity('User') %>> findOneByEmailIgnoreCase(String email);
 
     <%_ if (databaseType === 'couchbase') { _%>
         <%_ if (cacheManagerIsAvailable === true) { _%>
     @Cacheable(cacheNames = USERS_BY_LOGIN_CACHE)
         <%_ } _%>
-    default Optional<User> findOneByLogin(String login) {
-        return findById(User.PREFIX + ID_DELIMITER + login);
+    default Optional<<%= asEntity('User') %>> findOneByLogin(String login) {
+        return findById(<%= asEntity('User') %>.PREFIX + ID_DELIMITER + login);
     }
     <%_ } else if (databaseType === 'mongodb') { _%>
         <%_ if (cacheManagerIsAvailable === true) { _%>
     @Cacheable(cacheNames = USERS_BY_LOGIN_CACHE)
         <%_ } _%>
-    <% if (reactive) { %>Mono<% } else { %>Optional<% } %><User> findOneByLogin(String login);
+    <% if (reactive) { %>Mono<% } else { %>Optional<% } %><<%= asEntity('User') %>> findOneByLogin(String login);
     <%_ } else { _%>
-    Optional<User> findOneByLogin(String login);
+    Optional<<%= asEntity('User') %>> findOneByLogin(String login);
     <%_ } _%>
     <%_ if (databaseType === 'sql') { _%>
 
     @EntityGraph(attributePaths = "authorities")
-    Optional<User> findOneWithAuthoritiesById(<%= pkType %> id);
+    Optional<<%= asEntity('User') %>> findOneWithAuthoritiesById(<%= pkType %> id);
 
     @EntityGraph(attributePaths = "authorities")
     <%_ if (cacheManagerIsAvailable === true) { _%>
     @Cacheable(cacheNames = USERS_BY_LOGIN_CACHE)
     <%_ } _%>
-    Optional<User> findOneWithAuthoritiesByLogin(String login);
+    Optional<<%= asEntity('User') %>> findOneWithAuthoritiesByLogin(String login);
 
     @EntityGraph(attributePaths = "authorities")
     <%_ if (cacheManagerIsAvailable === true) { _%>
     @Cacheable(cacheNames = USERS_BY_EMAIL_CACHE)
     <%_ } _%>
-    Optional<User> findOneWithAuthoritiesByEmail(String email);
+    Optional<<%= asEntity('User') %>> findOneWithAuthoritiesByEmail(String email);
     <%_ } _%>
 
-    <% if (reactive) { %>Flux<% } else { %>Page<% } %><User> findAllByLoginNot(Pageable pageable, String login);
+    <% if (reactive) { %>Flux<% } else { %>Page<% } %><<%= asEntity('User') %>> findAllByLoginNot(Pageable pageable, String login);
     <%_ if (reactive) { _%>
 
     Mono<Long> countAllByLoginNot(String anonymousUser);
@@ -165,7 +165,7 @@ public class UserRepository {
 
     private final Validator validator;
 
-    private Mapper<User> mapper;
+    private Mapper<<%= asEntity('User') %>> mapper;
 
     private PreparedStatement findAllStmt;
 
@@ -204,7 +204,7 @@ public class UserRepository {
     public UserRepository(Session session, Validator validator) {
         this.session = session;
         this.validator = validator;
-        mapper = new MappingManager(session).mapper(User.class);
+        mapper = new MappingManager(session).mapper(<%= asEntity('User') %>.class);
 
         findAllStmt = session.prepare("SELECT * FROM user");
 
@@ -269,17 +269,17 @@ public class UserRepository {
         truncateByEmailStmt = session.prepare("TRUNCATE user_by_email");
     }
 
-    public Optional<User> findById(String id) {
+    public Optional<<%= asEntity('User') %>> findById(String id) {
         return Optional.ofNullable(mapper.get(id));
     }
 
-    public Optional<User> findOneByActivationKey(String activationKey) {
+    public Optional<<%= asEntity('User') %>> findOneByActivationKey(String activationKey) {
         BoundStatement stmt = findOneByActivationKeyStmt.bind();
         stmt.setString("activation_key", activationKey);
         return findOneFromIndex(stmt);
     }
 
-    public Optional<User> findOneByResetKey(String resetKey) {
+    public Optional<<%= asEntity('User') %>> findOneByResetKey(String resetKey) {
         BoundStatement stmt = findOneByResetKeyStmt.bind();
         stmt.setString("reset_key", resetKey);
         return findOneFromIndex(stmt);
@@ -288,7 +288,7 @@ public class UserRepository {
     <%_ if (cacheManagerIsAvailable === true) { _%>
     @Cacheable(cacheNames = USERS_BY_EMAIL_CACHE)
     <%_ } _%>
-    public Optional<User> findOneByEmailIgnoreCase(String email) {
+    public Optional<<%= asEntity('User') %>> findOneByEmailIgnoreCase(String email) {
         BoundStatement stmt = findOneByEmailStmt.bind();
         stmt.setString("email", email.toLowerCase());
         return findOneFromIndex(stmt);
@@ -297,22 +297,22 @@ public class UserRepository {
     <%_ if (cacheManagerIsAvailable === true) { _%>
     @Cacheable(cacheNames = USERS_BY_LOGIN_CACHE)
     <%_ } _%>
-    public Optional<User> findOneByLogin(String login) {
+    public Optional<<%= asEntity('User') %>> findOneByLogin(String login) {
         BoundStatement stmt = findOneByLoginStmt.bind();
         stmt.setString("login", login);
         return findOneFromIndex(stmt);
     }
 
-    public List<User> findAll() {
+    public List<<%= asEntity('User') %>> findAll() {
         return mapper.map(session.execute(findAllStmt.bind())).all();
     }
 
-    public User save(User user) {
-        Set<ConstraintViolation<User>> violations = validator.validate(user);
+    public <%= asEntity('User') %> save(<%= asEntity('User') %> user) {
+        Set<ConstraintViolation<<%= asEntity('User') %>>> violations = validator.validate(user);
         if (violations != null && !violations.isEmpty()) {
             throw new ConstraintViolationException(violations);
         }
-        User oldUser = mapper.get(user.getId());
+        <%= asEntity('User') %> oldUser = mapper.get(user.getId());
         if (oldUser != null) {
             if (!StringUtils.isEmpty(oldUser.getActivationKey()) && !oldUser.getActivationKey().equals(user.getActivationKey())) {
                 session.execute(deleteByActivationKeyStmt.bind().setString("activation_key", oldUser.getActivationKey()));
@@ -349,7 +349,7 @@ public class UserRepository {
         return user;
     }
 
-    public void delete(User user) {
+    public void delete(<%= asEntity('User') %> user) {
         BatchStatement batch = new BatchStatement();
         batch.add(mapper.deleteQuery(user));
         if (!StringUtils.isEmpty(user.getActivationKey())) {
@@ -363,7 +363,7 @@ public class UserRepository {
         session.execute(batch);
     }
 
-    private Optional<User> findOneFromIndex(BoundStatement stmt) {
+    private Optional<<%= asEntity('User') %>> findOneFromIndex(BoundStatement stmt) {
         ResultSet rs = session.execute(stmt);
         if (rs.isExhausted()) {
             return Optional.empty();
diff --git a/generators/server/templates/src/main/java/package/repository/search/UserSearchRepository.java.ejs b/generators/server/templates/src/main/java/package/repository/search/UserSearchRepository.java.ejs
index 368be86fe2..767bcaed1b 100644
--- a/generators/server/templates/src/main/java/package/repository/search/UserSearchRepository.java.ejs
+++ b/generators/server/templates/src/main/java/package/repository/search/UserSearchRepository.java.ejs
@@ -18,7 +18,7 @@
 -%>
 package <%=packageName%>.repository.search;
 
-import <%=packageName%>.domain.User;
+import <%=packageName%>.domain.<%= asEntity('User') %>;
 import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;<% if (databaseType === 'cassandra') { %>
 
 import java.util.UUID;<% } %>
@@ -26,5 +26,5 @@ import java.util.UUID;<% } %>
 /**
  * Spring Data Elasticsearch repository for the User entity.
  */
-public interface UserSearchRepository extends ElasticsearchRepository<User, <% if (databaseType === 'sql' && authenticationType !== 'oauth2') { %>Long<% } %><% if (databaseType === 'cassandra' || databaseType === 'mongodb' || authenticationType === 'oauth2') { %>String<% } %>> {
+public interface UserSearchRepository extends ElasticsearchRepository<<%= asEntity('User') %>, <% if (databaseType === 'sql' && authenticationType !== 'oauth2') { %>Long<% } %><% if (databaseType === 'cassandra' || databaseType === 'mongodb' || authenticationType === 'oauth2') { %>String<% } %>> {
 }
diff --git a/generators/server/templates/src/main/java/package/security/DomainUserDetailsService.java.ejs b/generators/server/templates/src/main/java/package/security/DomainUserDetailsService.java.ejs
index 250240fa04..ebc1713b75 100644
--- a/generators/server/templates/src/main/java/package/security/DomainUserDetailsService.java.ejs
+++ b/generators/server/templates/src/main/java/package/security/DomainUserDetailsService.java.ejs
@@ -18,7 +18,7 @@
 -%>
 package <%= packageName %>.security;
 
-import <%= packageName %>.domain.User;
+import <%= packageName %>.domain.<%= asEntity('User') %>;
 import <%= packageName %>.repository<% if (reactive) { %>.reactive<% } %>.UserRepository;
 import org.hibernate.validator.internal.constraintvalidators.hv.EmailValidator;
 import org.slf4j.Logger;
@@ -84,7 +84,7 @@ public class DomainUserDetailsService implements <% if (reactive) { %>Reactive<%
 
     }
 
-    private org.springframework.security.core.userdetails.User createSpringSecurityUser(String lowercaseLogin, User user) {
+    private org.springframework.security.core.userdetails.User createSpringSecurityUser(String lowercaseLogin, <%= asEntity('User') %> user) {
         if (!user.getActivated()) {
             throw new UserNotActivatedException("User " + lowercaseLogin + " was not activated");
         }
diff --git a/generators/server/templates/src/main/java/package/security/oauth2/AuthorizationHeaderUtil.java.ejs b/generators/server/templates/src/main/java/package/security/oauth2/AuthorizationHeaderUtil.java.ejs
index f37cbf2502..7015bbe21b 100644
--- a/generators/server/templates/src/main/java/package/security/oauth2/AuthorizationHeaderUtil.java.ejs
+++ b/generators/server/templates/src/main/java/package/security/oauth2/AuthorizationHeaderUtil.java.ejs
@@ -20,8 +20,6 @@ package <%=packageName%>.security.oauth2;
 
 import java.util.Optional;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.security.oauth2.client.OAuth2RestTemplate;
 import org.springframework.security.oauth2.client.http.AccessTokenRequiredException;
 import org.springframework.security.oauth2.client.resource.UserRedirectRequiredException;
@@ -32,8 +30,6 @@ import org.springframework.util.StringUtils;
 @Component
 public class AuthorizationHeaderUtil {
 
-    private final Logger log = LoggerFactory.getLogger(getClass());
-
     private final OAuth2RestTemplate oAuth2RestTemplate;
 
     public AuthorizationHeaderUtil(OAuth2RestTemplate oAuth2RestTemplate) {
diff --git a/generators/server/templates/src/main/java/package/security/oauth2/CachedUserInfoTokenServices.java.ejs b/generators/server/templates/src/main/java/package/security/oauth2/CachedUserInfoTokenServices.java.ejs
index 5753d0227f..0bb636f988 100644
--- a/generators/server/templates/src/main/java/package/security/oauth2/CachedUserInfoTokenServices.java.ejs
+++ b/generators/server/templates/src/main/java/package/security/oauth2/CachedUserInfoTokenServices.java.ejs
@@ -22,8 +22,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.boot.autoconfigure.security.oauth2.resource.UserInfoTokenServices;
 import org.springframework.cache.annotation.Cacheable;
-import org.springframework.security.core.AuthenticationException;
-import org.springframework.security.oauth2.common.exceptions.InvalidTokenException;
 import org.springframework.security.oauth2.provider.OAuth2Authentication;
 
 public class CachedUserInfoTokenServices extends UserInfoTokenServices {
@@ -36,7 +34,7 @@ public class CachedUserInfoTokenServices extends UserInfoTokenServices {
 
     @Override
     @Cacheable("oAuth2Authentication")
-    public OAuth2Authentication loadAuthentication(String accessToken) throws AuthenticationException, InvalidTokenException {
+    public OAuth2Authentication loadAuthentication(String accessToken) {
         log.debug("Getting user information from OpenID Connect server");
         return super.loadAuthentication(accessToken);
     }
diff --git a/generators/server/templates/src/main/java/package/service/MailService.java.ejs b/generators/server/templates/src/main/java/package/service/MailService.java.ejs
index e795c71c83..072266a264 100644
--- a/generators/server/templates/src/main/java/package/service/MailService.java.ejs
+++ b/generators/server/templates/src/main/java/package/service/MailService.java.ejs
@@ -18,7 +18,7 @@
 -%>
 package <%=packageName%>.service;
 
-import <%=packageName%>.domain.User;
+import <%=packageName%>.domain.<%= asEntity('User') %>;
 
 import io.github.jhipster.config.JHipsterProperties;
 
@@ -92,7 +92,7 @@ public class MailService {
     }
 
     @Async
-    public void sendEmailFromTemplate(User user, String templateName, String titleKey) {
+    public void sendEmailFromTemplate(<%= asEntity('User') %> user, String templateName, String titleKey) {
         Locale locale = Locale.forLanguageTag(user.getLangKey());
         Context context = new Context(locale);
         context.setVariable(USER, user);
@@ -105,19 +105,19 @@ public class MailService {
     <%_ if (authenticationType !== 'oauth2') { _%>
 
     @Async
-    public void sendActivationEmail(User user) {
+    public void sendActivationEmail(<%= asEntity('User') %> user) {
         log.debug("Sending activation email to '{}'", user.getEmail());
         sendEmailFromTemplate(user, "mail/activationEmail", "email.activation.title");
     }
 
     @Async
-    public void sendCreationEmail(User user) {
+    public void sendCreationEmail(<%= asEntity('User') %> user) {
         log.debug("Sending creation email to '{}'", user.getEmail());
         sendEmailFromTemplate(user, "mail/creationEmail", "email.activation.title");
     }
 
     @Async
-    public void sendPasswordResetMail(User user) {
+    public void sendPasswordResetMail(<%= asEntity('User') %> user) {
         log.debug("Sending password reset email to '{}'", user.getEmail());
         sendEmailFromTemplate(user, "mail/passwordResetEmail", "email.reset.title");
     }
diff --git a/generators/server/templates/src/main/java/package/service/UserService.java.ejs b/generators/server/templates/src/main/java/package/service/UserService.java.ejs
index 72bca398ee..0df7304920 100644
--- a/generators/server/templates/src/main/java/package/service/UserService.java.ejs
+++ b/generators/server/templates/src/main/java/package/service/UserService.java.ejs
@@ -22,7 +22,7 @@ import <%=packageName%>.config.Constants;
 <%_ if (databaseType === 'sql' || databaseType === 'mongodb' || databaseType === 'couchbase') { _%>
 import <%=packageName%>.domain.Authority;
 <%_ } _%>
-import <%=packageName%>.domain.User;
+import <%=packageName%>.domain.<%= asEntity('User') %>;
 <%_ if (databaseType === 'sql' || databaseType === 'mongodb' || databaseType === 'couchbase') { _%>
 import <%=packageName%>.repository<% if (reactive) { %>.reactive<% } %>.AuthorityRepository;
     <%_ if (authenticationType === 'session') { _%>
@@ -37,7 +37,7 @@ import <%=packageName%>.repository.search.UserSearchRepository;
 import <%=packageName%>.security.AuthoritiesConstants;
 <%_ } _%>
 import <%=packageName%>.security.SecurityUtils;
-import <%=packageName%>.service.dto.UserDTO;
+import <%=packageName%>.service.dto.<%= asDto('User') %>;
 <%_ if (authenticationType !== 'oauth2') { _%>
 import <%=packageName%>.service.util.RandomUtil;
 import <%=packageName%>.web.rest.errors.*;
@@ -148,7 +148,7 @@ public class UserService {
     }
 <%_ if (authenticationType !== 'oauth2') { _%>
 
-    public <% if (reactive) { %>Mono<% } else { %>Optional<% } %><User> activateRegistration(String key) {
+    public <% if (reactive) { %>Mono<% } else { %>Optional<% } %><<%= asEntity('User') %>> activateRegistration(String key) {
         log.debug("Activating user for activation key {}", key);
         return userRepository.findOneByActivationKey(key)
             .<% if (reactive) { %>flatMap<% } else { %>map<% } %>(user -> {
@@ -178,7 +178,7 @@ public class UserService {
             <%_ } _%>
     }
 
-    public <% if (reactive) { %>Mono<% } else { %>Optional<% } %><User> completePasswordReset(String newPassword, String key) {
+    public <% if (reactive) { %>Mono<% } else { %>Optional<% } %><<%= asEntity('User') %>> completePasswordReset(String newPassword, String key) {
         log.debug("Reset user password for reset key {}", key);
         return userRepository.findOneByResetKey(key)
             .filter(user -> user.getResetDate().isAfter(Instant.now().minusSeconds(86400)))
@@ -202,9 +202,9 @@ public class UserService {
             <%_ } _%>
     }
 
-    public <% if (reactive) { %>Mono<% } else { %>Optional<% } %><User> requestPasswordReset(String mail) {
+    public <% if (reactive) { %>Mono<% } else { %>Optional<% } %><<%= asEntity('User') %>> requestPasswordReset(String mail) {
         return userRepository.findOneByEmailIgnoreCase(mail)
-            .filter(User::getActivated)
+            .filter(<%= asEntity('User') %>::getActivated)
             .<% if (reactive) { %>flatMap<% } else { %>map<% } %>(user -> {
                 user.setResetKey(RandomUtil.generateResetKey());
                 user.setResetDate(Instant.now());
@@ -224,7 +224,7 @@ public class UserService {
             <%_ } _%>
     }
 
-    public <% if (reactive) { %>Mono<User><% } else { %>User<% } %> registerUser(UserDTO userDTO, String password) {
+    public <% if (reactive) { %>Mono<<%= asEntity('User') %>><% } else { %><%= asEntity('User') %><% } %> registerUser(<%= asDto('User') %> userDTO, String password) {
     <%_ if (!reactive) { _%>
         userRepository.findOneByLogin(userDTO.getLogin().toLowerCase()).ifPresent(existingUser -> {
             boolean removed = removeNonActivatedUser(existingUser);
@@ -238,7 +238,7 @@ public class UserService {
                 throw new EmailAlreadyUsedException();
             }
         });
-        User newUser = new User();
+        <%= asEntity('User') %> newUser = new <%= asEntity('User') %>();
         <%_ if (databaseType === 'cassandra') { _%>
         newUser.setId(UUID.randomUUID().toString());
         <%_ } _%>
@@ -294,7 +294,7 @@ public class UserService {
                     throw new EmailAlreadyUsedException();
                 }
             })
-            .thenReturn(new User())
+            .thenReturn(new <%= asEntity('User') %>())
             .flatMap(newUser -> {
                 String encryptedPassword = passwordEncoder.encode(password);
                 newUser.setLogin(userDTO.getLogin().toLowerCase());
@@ -321,7 +321,7 @@ public class UserService {
     <%_ } _%>
     }
 
-    private boolean removeNonActivatedUser(User existingUser){
+    private boolean removeNonActivatedUser(<%= asEntity('User') %> existingUser){
         if (existingUser.getActivated()) {
              return false;
         }
@@ -335,8 +335,8 @@ public class UserService {
         return true;
     }
 
-    public <% if (reactive) { %>Mono<User><% } else { %>User<% } %> createUser(UserDTO userDTO) {
-        User user = new User();<% if (databaseType === 'cassandra') { %>
+    public <% if (reactive) { %>Mono<<%= asEntity('User') %>><% } else { %><%= asEntity('User') %><% } %> createUser(<%= asDto('User') %> userDTO) {
+        <%= asEntity('User') %> user = new <%= asEntity('User') %>();<% if (databaseType === 'cassandra') { %>
         user.setId(UUID.randomUUID().toString());<% } %>
         user.setLogin(userDTO.getLogin().toLowerCase());
         user.setFirstName(userDTO.getFirstName());
@@ -440,7 +440,7 @@ public class UserService {
      * @param userDTO user to update
      * @return updated user
      */
-    public <% if (reactive) { %>Mono<% } else { %>Optional<% } %><UserDTO> updateUser(UserDTO userDTO) {
+    public <% if (reactive) { %>Mono<% } else { %>Optional<% } %><<%= asDto('User') %>> updateUser(<%= asDto('User') %> userDTO) {
         <%_ if (!reactive) { _%>
         return Optional.of(userRepository
             .findById(userDTO.getId()))
@@ -506,7 +506,7 @@ public class UserService {
             <%_ } _%>
             .doOnNext(user -> log.debug("Changed Information for User: {}", user))
         <%_ } _%>
-            .map(UserDTO::new);
+            .map(<%= asDto('User') %>::new);
     }
 
     <%_ if (!reactive) { _%>
@@ -523,7 +523,7 @@ public class UserService {
         });
     }
     <%_ } else { _%>
-    private Mono<User> updateUser(User user) {
+    private Mono<<%= asEntity('User') %>> updateUser(<%= asEntity('User') %> user) {
         return SecurityUtils.getCurrentUserLogin()
             .switchIfEmpty(Mono.just(Constants.SYSTEM_ACCOUNT))
             .flatMap(login -> {
@@ -532,7 +532,7 @@ public class UserService {
             });
     }
 
-    private Mono<User> createUser(User user) {
+    private Mono<<%= asEntity('User') %>> createUser(<%= asEntity('User') %> user) {
         return SecurityUtils.getCurrentUserLogin()
             .switchIfEmpty(Mono.just(Constants.SYSTEM_ACCOUNT))
             .flatMap(login -> {
@@ -589,13 +589,13 @@ public class UserService {
     @Transactional(readOnly = true)
     <%_ } _%>
     <%_ if (databaseType === 'sql' || databaseType === 'mongodb' || databaseType === 'couchbase') { _%>
-    public <% if (reactive) { %>Flux<% } else { %>Page<% } %><UserDTO> getAllManagedUsers(Pageable pageable) {
-        return userRepository.findAllByLoginNot(pageable, Constants.ANONYMOUS_USER).map(UserDTO::new);
+    public <% if (reactive) { %>Flux<% } else { %>Page<% } %><<%= asDto('User') %>> getAllManagedUsers(Pageable pageable) {
+        return userRepository.findAllByLoginNot(pageable, Constants.ANONYMOUS_USER).map(<%= asDto('User') %>::new);
     }<% } else { // Cassandra %>
-    public List<UserDTO> getAllManagedUsers() {
+    public List<<%= asDto('User') %>> getAllManagedUsers() {
         return userRepository.findAll().stream()
             .filter(user -> !Constants.ANONYMOUS_USER.equals(user.getLogin()))
-            .map(UserDTO::new)
+            .map(<%= asDto('User') %>::new)
             .collect(Collectors.toList());
     }<% } %>
 
@@ -608,7 +608,7 @@ public class UserService {
     <%_ if (databaseType === 'sql') { _%>
     @Transactional(readOnly = true)
     <%_ } _%>
-    public <% if (reactive) { %>Mono<% } else { %>Optional<% } %><User> getUserWithAuthoritiesByLogin(String login) {
+    public <% if (reactive) { %>Mono<% } else { %>Optional<% } %><<%= asEntity('User') %>> getUserWithAuthoritiesByLogin(String login) {
         <%_ if (databaseType === 'sql') { _%>
         return userRepository.findOneWithAuthoritiesByLogin(login);
         <%_ } else { // MongoDB, Couchbase and Cassandra _%>
@@ -619,7 +619,7 @@ public class UserService {
     <%_ if (databaseType === 'sql') { _%>
     @Transactional(readOnly = true)
     <%_ } _%>
-    public <% if (reactive) { %>Mono<% } else { %>Optional<% } %><User> getUserWithAuthorities(<%= pkType %> id) {
+    public <% if (reactive) { %>Mono<% } else { %>Optional<% } %><<%= asEntity('User') %>> getUserWithAuthorities(<%= pkType %> id) {
         <%_ if (databaseType === 'sql') { _%>
         return userRepository.findOneWithAuthoritiesById(id);
         <%_ } else { // MongoDB, Couchbase and and Cassandra _%>
@@ -630,7 +630,7 @@ public class UserService {
     <%_ if (databaseType === 'sql') { _%>
     @Transactional(readOnly = true)
     <%_ } _%>
-    public <% if (reactive) { %>Mono<% } else { %>Optional<% } %><User> getUserWithAuthorities() {
+    public <% if (reactive) { %>Mono<% } else { %>Optional<% } %><<%= asEntity('User') %>> getUserWithAuthorities() {
         return SecurityUtils.getCurrentUserLogin().flatMap(userRepository::findOne<% if (databaseType === 'sql') { %>WithAuthorities<% } %>ByLogin);
     }
     <%_ if ((databaseType === 'sql' || databaseType === 'mongodb' || databaseType === 'couchbase') && authenticationType === 'session') { _%>
@@ -646,7 +646,7 @@ public class UserService {
         LocalDate now = LocalDate.now();
         persistentTokenRepository.findByTokenDateBefore(now.minusMonths(1)).forEach(token -> {
             log.debug("Deleting token {}", token.getSeries());<% if (databaseType === 'sql') { %>
-            User user = token.getUser();
+            <%= asEntity('User') %> user = token.getUser();
             user.getPersistentTokens().remove(token);<% } %>
             persistentTokenRepository.delete(token);
         });
@@ -702,10 +702,10 @@ public class UserService {
      * @return the user from the authentication
      */
     @SuppressWarnings("unchecked")
-    public UserDTO getUserFromAuthentication(OAuth2Authentication authentication) {
+    public <%= asDto('User') %> getUserFromAuthentication(OAuth2Authentication authentication) {
         Object oauth2AuthenticationDetails = authentication.getDetails(); // should be an OAuth2AuthenticationDetails
         Map<String, Object> details = (Map<String, Object>) authentication.getUserAuthentication().getDetails();
-        User user = getUser(details);
+        <%= asEntity('User') %> user = getUser(details);
         Set<<% if (databaseType === 'couchbase') { %>String<% } else { %>Authority<% } %>> userAuthorities = extractAuthorities(authentication, details);
         user.setAuthorities(userAuthorities);
 
@@ -722,10 +722,10 @@ public class UserService {
         authentication.setDetails(oauth2AuthenticationDetails); // must be present in a gateway for TokenRelayFilter to work
         SecurityContextHolder.getContext().setAuthentication(authentication);
 
-        return new UserDTO(syncUserWithIdP(details, user));
+        return new <%= asDto('User') %>(syncUserWithIdP(details, user));
     }
 
-    private User syncUserWithIdP(Map<String, Object> details, User user) {
+    private <%= asEntity('User') %> syncUserWithIdP(Map<String, Object> details, <%= asEntity('User') %> user) {
         // save authorities in to sync user roles/groups between IdP and JHipster's local database
         Collection<String> dbAuthorities = getAuthorities();
         <%_ if (databaseType !== 'couchbase') { _%>
@@ -743,7 +743,7 @@ public class UserService {
             }
         }
         // save account in to sync users between IdP and JHipster's local database
-        Optional<User> existingUser = userRepository.findOneByLogin(user.getLogin());
+        Optional<<%= asEntity('User') %>> existingUser = userRepository.findOneByLogin(user.getLogin());
         if (existingUser.isPresent()) {
             // if IdP sends last updated information, use it to determine if an update should happen
             if (details.get("updated_at") != null) {
@@ -770,7 +770,7 @@ public class UserService {
         return user;
     }
 
-    private static UsernamePasswordAuthenticationToken getToken(Map<String, Object> details, User user, Set<GrantedAuthority> grantedAuthorities) {
+    private static UsernamePasswordAuthenticationToken getToken(Map<String, Object> details, <%= asEntity('User') %> user, Set<GrantedAuthority> grantedAuthorities) {
         // create UserDetails so #{principal.username} works
         UserDetails userDetails =
             new org.springframework.security.core.userdetails.User(user.getLogin(),
@@ -800,8 +800,8 @@ public class UserService {
         return userAuthorities;
     }
 
-    private static User getUser(Map<String, Object> details) {
-        User user = new User();
+    private static <%= asEntity('User') %> getUser(Map<String, Object> details) {
+        <%= asEntity('User') %> user = new <%= asEntity('User') %>();
         user.setId((String) details.get("sub"));
         user.setLogin(((String) details.get("preferred_username")).toLowerCase());
         if (details.get("given_name") != null) {
@@ -821,10 +821,10 @@ public class UserService {
         } else if (details.get("locale") != null) {
             String locale = (String) details.get("locale");
             if (locale.contains("-")) {
-              String langKey = locale.substring(0, locale.indexOf("-"));
+              String langKey = locale.substring(0, locale.indexOf('-'));
               user.setLangKey(langKey);
             } else if (locale.contains("_")) {
-              String langKey = locale.substring(0, locale.indexOf("_"));
+              String langKey = locale.substring(0, locale.indexOf('_'));
               user.setLangKey(langKey);
             }
         }
@@ -852,7 +852,7 @@ public class UserService {
     <%_ } _%>
     <%_ if (cacheManagerIsAvailable === true) { _%>
 
-    private void clearUserCaches(User user) {
+    private void clearUserCaches(<%= asEntity('User') %> user) {
         Objects.requireNonNull(cacheManager.getCache(UserRepository.USERS_BY_LOGIN_CACHE)).evict(user.getLogin());
         Objects.requireNonNull(cacheManager.getCache(UserRepository.USERS_BY_EMAIL_CACHE)).evict(user.getEmail());
     }
diff --git a/generators/server/templates/src/main/java/package/service/dto/UserDTO.java.ejs b/generators/server/templates/src/main/java/package/service/dto/UserDTO.java.ejs
index aa80dc050d..41b66e0f81 100644
--- a/generators/server/templates/src/main/java/package/service/dto/UserDTO.java.ejs
+++ b/generators/server/templates/src/main/java/package/service/dto/UserDTO.java.ejs
@@ -21,7 +21,7 @@ package <%=packageName%>.service.dto;
 import <%=packageName%>.config.Constants;
 <% if (databaseType === 'sql' || databaseType === 'mongodb') { %>
 import <%=packageName%>.domain.Authority;<% } %>
-import <%=packageName%>.domain.User;
+import <%=packageName%>.domain.<%= asEntity('User') %>;
 
 import javax.validation.constraints.Email;
 import javax.validation.constraints.NotBlank;
@@ -38,7 +38,7 @@ import java.util.stream.Collectors;
 /**
  * A DTO representing a user, with his authorities.
  */
-public class UserDTO {
+public class <%= asDto('User') %> {
 
     private <% if (databaseType === 'mongodb' || databaseType === 'couchbase' || databaseType === 'cassandra' || authenticationType === 'oauth2') { %>String<% } else { %>Long<% } %> id;
 
@@ -79,11 +79,11 @@ public class UserDTO {
 
     private Set<String> authorities;
 
-    public UserDTO() {
+    public <%= asDto('User') %>() {
         // Empty constructor needed for Jackson.
     }
 
-    public UserDTO(User user) {
+    public <%= asDto('User') %>(<%= asEntity('User') %> user) {
         this.id = user.getId();
         this.login = user.getLogin();
         this.firstName = user.getFirstName();
@@ -219,7 +219,7 @@ public class UserDTO {
 
     @Override
     public String toString() {
-        return "UserDTO{" +
+        return "<%= asDto('User') %>{" +
             "login='" + login + '\'' +
             ", firstName='" + firstName + '\'' +
             ", lastName='" + lastName + '\'' +
diff --git a/generators/server/templates/src/main/java/package/service/mapper/UserMapper.java.ejs b/generators/server/templates/src/main/java/package/service/mapper/UserMapper.java.ejs
index c4805c71d7..1116c1b61a 100644
--- a/generators/server/templates/src/main/java/package/service/mapper/UserMapper.java.ejs
+++ b/generators/server/templates/src/main/java/package/service/mapper/UserMapper.java.ejs
@@ -21,8 +21,8 @@ package <%=packageName%>.service.mapper;
 <%_ if (databaseType === 'sql' || databaseType === 'mongodb') { _%>
 import <%=packageName%>.domain.Authority;
 <%_ } _%>
-import <%=packageName%>.domain.User;
-import <%=packageName%>.service.dto.UserDTO;
+import <%=packageName%>.domain.<%= asEntity('User') %>;
+import <%=packageName%>.service.dto.<%= asDto('User') %>;
 
 import org.springframework.stereotype.Service;
 
@@ -38,29 +38,29 @@ import java.util.stream.Collectors;
 @Service
 public class UserMapper {
 
-    public List<UserDTO> usersToUserDTOs(List<User> users) {
+    public List<<%= asDto('User') %>> usersToUserDTOs(List<<%= asEntity('User') %>> users) {
         return users.stream()
             .filter(Objects::nonNull)
             .map(this::userToUserDTO)
             .collect(Collectors.toList());
     }
 
-    public UserDTO userToUserDTO(User user) {
-        return new UserDTO(user);
+    public <%= asDto('User') %> userToUserDTO(<%= asEntity('User') %> user) {
+        return new <%= asDto('User') %>(user);
     }
 
-    public List<User> userDTOsToUsers(List<UserDTO> userDTOs) {
+    public List<<%= asEntity('User') %>> userDTOsToUsers(List<<%= asDto('User') %>> userDTOs) {
         return userDTOs.stream()
             .filter(Objects::nonNull)
             .map(this::userDTOToUser)
             .collect(Collectors.toList());
     }
 
-    public User userDTOToUser(UserDTO userDTO) {
+    public <%= asEntity('User') %> userDTOToUser(<%= asDto('User') %> userDTO) {
         if (userDTO == null) {
             return null;
         } else {
-            User user = new User();
+            <%= asEntity('User') %> user = new <%= asEntity('User') %>();
             user.setId(userDTO.getId());
             user.setLogin(userDTO.getLogin());
             user.setFirstName(userDTO.getFirstName());
@@ -114,11 +114,11 @@ public class UserMapper {
     }
     <%_ } _%>
 
-    public User userFromId(<% if (databaseType === 'mongodb' || databaseType === 'couchbase' || databaseType === 'cassandra' || authenticationType === 'oauth2') { %>String<% } else { %>Long<% } %> id) {
+    public <%= asEntity('User') %> userFromId(<% if (databaseType === 'mongodb' || databaseType === 'couchbase' || databaseType === 'cassandra' || authenticationType === 'oauth2') { %>String<% } else { %>Long<% } %> id) {
         if (id == null) {
             return null;
         }
-        User user = new User();
+        <%= asEntity('User') %> user = new <%= asEntity('User') %>();
         user.setId(id);
         return user;
     }
diff --git a/generators/server/templates/src/main/java/package/web/rest/AccountResource.java.ejs b/generators/server/templates/src/main/java/package/web/rest/AccountResource.java.ejs
index 2bb3ecf6e4..41aa742167 100644
--- a/generators/server/templates/src/main/java/package/web/rest/AccountResource.java.ejs
+++ b/generators/server/templates/src/main/java/package/web/rest/AccountResource.java.ejs
@@ -20,7 +20,7 @@ package <%=packageName%>.web.rest;
 
 <%_ if (authenticationType === 'oauth2') { _%>
 import <%=packageName%>.service.UserService;
-import <%=packageName%>.service.dto.UserDTO;
+import <%=packageName%>.service.dto.<%= asDto('User') %>;
 import <%=packageName%>.web.rest.errors.InternalServerErrorException;
 
 import org.slf4j.Logger;
@@ -69,14 +69,14 @@ public class AccountResource {
      */
     @GetMapping("/account")
     @SuppressWarnings("unchecked")
-    public UserDTO getAccount(Principal principal) {
+    public <%= asDto('User') %> getAccount(Principal principal) {
         if (principal != null) {
             if (principal instanceof OAuth2Authentication) {
                 return userService.getUserFromAuthentication((OAuth2Authentication) principal);
             } else {
                 // Allow Spring Security Test to be used to mock users in the database
                 return userService.getUserWithAuthorities()
-                    .map(UserDTO::new)
+                    .map(<%= asDto('User') %>::new)
                     .orElseThrow(() -> new InternalServerErrorException("User could not be found"));
             }
         } else {
@@ -91,14 +91,14 @@ import <%=packageName%>.domain.PersistentToken;
 import <%=packageName%>.repository.PersistentTokenRepository;
 <%_ } _%>
 <%_ if (!reactive) { _%>
-import <%=packageName%>.domain.User;
+import <%=packageName%>.domain.<%= asEntity('User') %>;
 <%_ } _%>
 import <%=packageName%>.repository<% if (reactive) { %>.reactive<% } %>.UserRepository;
 import <%=packageName%>.security.SecurityUtils;
 import <%=packageName%>.service.MailService;
 import <%=packageName%>.service.UserService;
 import <%=packageName%>.service.dto.PasswordChangeDTO;
-import <%=packageName%>.service.dto.UserDTO;
+import <%=packageName%>.service.dto.<%= asDto('User') %>;
 import <%=packageName%>.web.rest.errors.*;
 import <%=packageName%>.web.rest.vm.KeyAndPasswordVM;
 import <%=packageName%>.web.rest.vm.ManagedUserVM;
@@ -172,7 +172,7 @@ public class AccountResource {
             throw new InvalidPasswordException();
         }
         <%_ if (!reactive) { _%>
-        User user = userService.registerUser(managedUserVM, managedUserVM.getPassword());
+        <%= asEntity('User') %> user = userService.registerUser(managedUserVM, managedUserVM.getPassword());
         mailService.sendActivationEmail(user);
         <%_ } else { _%>
         return userService.registerUser(managedUserVM, managedUserVM.getPassword())
@@ -190,7 +190,7 @@ public class AccountResource {
     @GetMapping("/activate")
     public <% if (reactive) { %>Mono<Void><% } else { %>void<% } %> activateAccount(@RequestParam(value = "key") String key) {
         <%_ if (!reactive) { _%>
-        Optional<User> user = userService.activateRegistration(key);
+        Optional<<%= asEntity('User') %>> user = userService.activateRegistration(key);
         if (!user.isPresent()) {
             throw new InternalServerErrorException("No user was found for this activation key");
         }
@@ -226,9 +226,9 @@ public class AccountResource {
      * @throws RuntimeException 500 (Internal Server Error) if the user couldn't be returned
      */
     @GetMapping("/account")
-    public <% if (reactive) { %>Mono<UserDTO><% } else { %>UserDTO<% } %> getAccount() {
+    public <% if (reactive) { %>Mono<<%= asDto('User') %>><% } else { %><%= asDto('User') %><% } %> getAccount() {
         return userService.getUserWithAuthorities()
-            .map(UserDTO::new)
+            .map(<%= asDto('User') %>::new)
             <%_ if (!reactive) { _%>
             .orElseThrow(() -> new InternalServerErrorException("User could not be found"));
             <%_ } else { _%>
@@ -245,20 +245,20 @@ public class AccountResource {
      */
     @PostMapping("/account")
     <%_ if (!reactive) { _%>
-    public void saveAccount(@Valid @RequestBody UserDTO userDTO) {
+    public void saveAccount(@Valid @RequestBody <%= asDto('User') %> userDTO) {
         String userLogin = SecurityUtils.getCurrentUserLogin().orElseThrow(() -> new InternalServerErrorException("Current user login not found"));
-        Optional<User> existingUser = userRepository.findOneByEmailIgnoreCase(userDTO.getEmail());
+        Optional<<%= asEntity('User') %>> existingUser = userRepository.findOneByEmailIgnoreCase(userDTO.getEmail());
         if (existingUser.isPresent() && (!existingUser.get().getLogin().equalsIgnoreCase(userLogin))) {
             throw new EmailAlreadyUsedException();
         }
-        Optional<User> user = userRepository.findOneByLogin(userLogin);
+        Optional<<%= asEntity('User') %>> user = userRepository.findOneByLogin(userLogin);
         if (!user.isPresent()) {
             throw new InternalServerErrorException("User could not be found");
         }
         userService.updateUser(userDTO.getFirstName(), userDTO.getLastName(), userDTO.getEmail(),
             userDTO.getLangKey()<% if (databaseType === 'mongodb' || databaseType === 'couchbase' || databaseType === 'sql') { %>, userDTO.getImageUrl()<% } %>);
     <%_ } else { _%>
-    public Mono<Void> saveAccount(@Valid @RequestBody UserDTO userDTO) {
+    public Mono<Void> saveAccount(@Valid @RequestBody <%= asDto('User') %> userDTO) {
         return SecurityUtils.getCurrentUserLogin()
             .switchIfEmpty(Mono.error(new InternalServerErrorException("Current user login not found")))
             .flatMap(userLogin -> userRepository.findOneByEmailIgnoreCase(userDTO.getEmail())
@@ -370,7 +370,7 @@ public class AccountResource {
             throw new InvalidPasswordException();
         }
         <%_ if (!reactive) { _%>
-        Optional<User> user =
+        Optional<<%= asEntity('User') %>> user =
             userService.completePasswordReset(keyAndPassword.getNewPassword(), keyAndPassword.getKey());
 
         if (!user.isPresent()) {
diff --git a/generators/server/templates/src/main/java/package/web/rest/UserResource.java.ejs b/generators/server/templates/src/main/java/package/web/rest/UserResource.java.ejs
index cf6f551811..962cbdc0ef 100644
--- a/generators/server/templates/src/main/java/package/web/rest/UserResource.java.ejs
+++ b/generators/server/templates/src/main/java/package/web/rest/UserResource.java.ejs
@@ -20,7 +20,7 @@ package <%=packageName%>.web.rest;
 
 import <%=packageName%>.config.Constants;
 <%_ if (authenticationType !== 'oauth2' || searchEngine === 'elasticsearch') { _%>
-import <%=packageName%>.domain.User;
+import <%=packageName%>.domain.<%= asEntity('User') %>;
 <%_ } _%>
 <%_ if (authenticationType !== 'oauth2') { _%>
 import <%=packageName%>.repository<% if (reactive) { %>.reactive<% } %>.UserRepository;
@@ -33,7 +33,7 @@ import <%=packageName%>.security.AuthoritiesConstants;
 import <%=packageName%>.service.MailService;
 <%_ } _%>
 import <%=packageName%>.service.UserService;
-import <%=packageName%>.service.dto.UserDTO;
+import <%=packageName%>.service.dto.<%= asDto('User') %>;
 <%_ if (authenticationType !== 'oauth2') { _%>
 import <%=packageName%>.web.rest.errors.BadRequestAlertException;
 import <%=packageName%>.web.rest.errors.EmailAlreadyUsedException;
@@ -160,7 +160,7 @@ public class UserResource {
      */
     @PostMapping("/users")
     @PreAuthorize("hasRole(\"" + AuthoritiesConstants.ADMIN + "\")")
-    public <% if (reactive) { %>Mono<ResponseEntity<User>><% } else { %>ResponseEntity<User><% } %> createUser(@Valid @RequestBody UserDTO userDTO)<% if (!reactive) { %> throws URISyntaxException<% } %> {
+    public <% if (reactive) { %>Mono<ResponseEntity<<%= asEntity('User') %>>><% } else { %>ResponseEntity<<%= asEntity('User') %>><% } %> createUser(@Valid @RequestBody <%= asDto('User') %> userDTO)<% if (!reactive) { %> throws URISyntaxException<% } %> {
         log.debug("REST request to save User : {}", userDTO);
 
         if (userDTO.getId() != null) {
@@ -172,7 +172,7 @@ public class UserResource {
         } else if (userRepository.findOneByEmailIgnoreCase(userDTO.getEmail()).isPresent()) {
             throw new EmailAlreadyUsedException();
         } else {
-            User newUser = userService.createUser(userDTO);
+            <%= asEntity('User') %> newUser = userService.createUser(userDTO);
             mailService.sendCreationEmail(newUser);
             return ResponseEntity.created(new URI("/api/users/" + newUser.getLogin()))
                 .headers(HeaderUtil.createAlert(<% if (enableTranslation) {%> "userManagement.created"<% } else { %> "A user is created with identifier " + newUser.getLogin()<% } %>, newUser.getLogin()))
@@ -219,9 +219,9 @@ public class UserResource {
     @PutMapping("/users")
     @PreAuthorize("hasRole(\"" + AuthoritiesConstants.ADMIN + "\")")
     <%_ if (!reactive) { _%>
-    public ResponseEntity<UserDTO> updateUser(@Valid @RequestBody UserDTO userDTO) {
+    public ResponseEntity<<%= asDto('User') %>> updateUser(@Valid @RequestBody <%= asDto('User') %> userDTO) {
         log.debug("REST request to update User : {}", userDTO);
-        Optional<User> existingUser = userRepository.findOneByEmailIgnoreCase(userDTO.getEmail());
+        Optional<<%= asEntity('User') %>> existingUser = userRepository.findOneByEmailIgnoreCase(userDTO.getEmail());
         if (existingUser.isPresent() && (!existingUser.get().getId().equals(userDTO.getId()))) {
             throw new EmailAlreadyUsedException();
         }
@@ -229,12 +229,12 @@ public class UserResource {
         if (existingUser.isPresent() && (!existingUser.get().getId().equals(userDTO.getId()))) {
             throw new LoginAlreadyUsedException();
         }
-        Optional<UserDTO> updatedUser = userService.updateUser(userDTO);
+        Optional<<%= asDto('User') %>> updatedUser = userService.updateUser(userDTO);
 
         return ResponseUtil.wrapOrNotFound(updatedUser,
             HeaderUtil.createAlert(<% if (enableTranslation) { %>"userManagement.updated"<% } else { %>"A user is updated with identifier " + userDTO.getLogin()<% } %>, userDTO.getLogin()));
     <%_ } else { _%>
-    public Mono<ResponseEntity<UserDTO>> updateUser(@Valid @RequestBody UserDTO userDTO) {
+    public Mono<ResponseEntity<<%= asDto('User') %>>> updateUser(@Valid @RequestBody <%= asDto('User') %> userDTO) {
         log.debug("REST request to update User : {}", userDTO);
         return userRepository.findOneByEmailIgnoreCase(userDTO.getEmail())
             .filter(user -> !user.getId().equals(userDTO.getId()))
@@ -271,12 +271,12 @@ public class UserResource {
     @GetMapping("/users")
     <%_ if (databaseType === 'sql' || databaseType === 'mongodb' || databaseType === 'couchbase') { _%>
         <%_ if (!reactive) { _%>
-    public ResponseEntity<List<UserDTO>> getAllUsers(Pageable pageable) {
-        final Page<UserDTO> page = userService.getAllManagedUsers(pageable);
+    public ResponseEntity<List<<%= asDto('User') %>>> getAllUsers(Pageable pageable) {
+        final Page<<%= asDto('User') %>> page = userService.getAllManagedUsers(pageable);
         HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/users");
         return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
         <%_ } else { _%>
-    public Mono<ResponseEntity<Flux<UserDTO>>> getAllUsers(Pageable pageable) {
+    public Mono<ResponseEntity<Flux<<%= asDto('User') %>>>> getAllUsers(Pageable pageable) {
         return userService.countManagedUsers()
             .map(total -> new PageImpl<>(new ArrayList<>(), pageable, total))
             .map(page -> PaginationUtil.generatePaginationHttpHeaders(page, "/api/users"))
@@ -293,8 +293,8 @@ public class UserResource {
         return userService.getAuthorities()<% if (reactive) { %>.collectList()<% } %>;
     }
     <%_ } else { // Cassandra _%>
-    public ResponseEntity<List<UserDTO>> getAllUsers() {
-        final List<UserDTO> userDTOs = userService.getAllManagedUsers();
+    public ResponseEntity<List<<%= asDto('User') %>>> getAllUsers() {
+        final List<<%= asDto('User') %>> userDTOs = userService.getAllManagedUsers();
         return new ResponseEntity<>(userDTOs, HttpStatus.OK);
     }
     <%_ } _%>
@@ -307,16 +307,16 @@ public class UserResource {
      */
     @GetMapping("/users/{login:" + Constants.LOGIN_REGEX + "}")
     <%_ if (!reactive) { _%>
-    public ResponseEntity<UserDTO> getUser(@PathVariable String login) {
+    public ResponseEntity<<%= asDto('User') %>> getUser(@PathVariable String login) {
         log.debug("REST request to get User : {}", login);
         return ResponseUtil.wrapOrNotFound(
             userService.getUserWithAuthoritiesByLogin(login)
-                .map(UserDTO::new));
+                .map(<%= asDto('User') %>::new));
     <%_ } else { _%>
-    public Mono<UserDTO> getUser(@PathVariable String login) {
+    public Mono<<%= asDto('User') %>> getUser(@PathVariable String login) {
         log.debug("REST request to get User : {}", login);
         return userService.getUserWithAuthoritiesByLogin(login)
-            .map(UserDTO::new)
+            .map(<%= asDto('User') %>::new)
             .switchIfEmpty(Mono.error(new ResponseStatusException(HttpStatus.NOT_FOUND)));
     <%_ } _%>
     }
@@ -353,7 +353,7 @@ public class UserResource {
      * @return the result of the search
      */
     @GetMapping("/_search/users/{query}")
-    public List<User> search(@PathVariable String query) {
+    public List<<%= asEntity('User') %>> search(@PathVariable String query) {
         return StreamSupport
             .stream(userSearchRepository.search(queryStringQuery(query)).spliterator(), false)
             .collect(Collectors.toList());
diff --git a/generators/server/templates/src/main/java/package/web/rest/vm/ManagedUserVM.java.ejs b/generators/server/templates/src/main/java/package/web/rest/vm/ManagedUserVM.java.ejs
index 307c472e65..00a4dc2b2e 100644
--- a/generators/server/templates/src/main/java/package/web/rest/vm/ManagedUserVM.java.ejs
+++ b/generators/server/templates/src/main/java/package/web/rest/vm/ManagedUserVM.java.ejs
@@ -18,15 +18,15 @@
 -%>
 package <%=packageName%>.web.rest.vm;
 
-import <%=packageName%>.service.dto.UserDTO;
+import <%=packageName%>.service.dto.<%= asDto('User') %>;
 <%_ if (authenticationType !== 'oauth2') { _%>
 import javax.validation.constraints.Size;
 <%_ } _%>
 
 /**
- * View Model extending the UserDTO, which is meant to be used in the user management UI.
+ * View Model extending the <%= asDto('User') %>, which is meant to be used in the user management UI.
  */
-public class ManagedUserVM extends UserDTO {
+public class ManagedUserVM extends <%= asDto('User') %> {
 <%_ if (authenticationType !== 'oauth2') { _%>
 
     public static final int PASSWORD_MIN_LENGTH = 4;
diff --git a/generators/server/templates/src/main/resources/config/couchmove/changelog/V0.1__initial_setup/user__admin.json.ejs b/generators/server/templates/src/main/resources/config/couchmove/changelog/V0.1__initial_setup/user__admin.json.ejs
index b30efebc94..04007c6d06 100644
--- a/generators/server/templates/src/main/resources/config/couchmove/changelog/V0.1__initial_setup/user__admin.json.ejs
+++ b/generators/server/templates/src/main/resources/config/couchmove/changelog/V0.1__initial_setup/user__admin.json.ejs
@@ -14,5 +14,5 @@
         "ROLE_USER",
         "ROLE_ADMIN"
     ],
-    "_class": "<%=packageName%>.domain.User"
+    "_class": "<%=packageName%>.domain.<%= asEntity('User') %>"
 }
diff --git a/generators/server/templates/src/main/resources/config/couchmove/changelog/V0.1__initial_setup/user__anonymoususer.json.ejs b/generators/server/templates/src/main/resources/config/couchmove/changelog/V0.1__initial_setup/user__anonymoususer.json.ejs
index b9c3e2e636..b28ed1f79d 100644
--- a/generators/server/templates/src/main/resources/config/couchmove/changelog/V0.1__initial_setup/user__anonymoususer.json.ejs
+++ b/generators/server/templates/src/main/resources/config/couchmove/changelog/V0.1__initial_setup/user__anonymoususer.json.ejs
@@ -11,5 +11,5 @@
     "created_by": "system",
     "last_modified_by": "system",
     "authorities": [],
-    "_class": "<%=packageName%>.domain.User"
+    "_class": "<%=packageName%>.domain.<%= asEntity('User') %>"
 }
diff --git a/generators/server/templates/src/main/resources/config/couchmove/changelog/V0.1__initial_setup/user__system.json.ejs b/generators/server/templates/src/main/resources/config/couchmove/changelog/V0.1__initial_setup/user__system.json.ejs
index 77a1a5e2eb..5a0e6c9f46 100644
--- a/generators/server/templates/src/main/resources/config/couchmove/changelog/V0.1__initial_setup/user__system.json.ejs
+++ b/generators/server/templates/src/main/resources/config/couchmove/changelog/V0.1__initial_setup/user__system.json.ejs
@@ -14,5 +14,5 @@
         "ROLE_USER",
         "ROLE_ADMIN"
     ],
-    "_class": "<%=packageName%>.domain.User"
+    "_class": "<%=packageName%>.domain.<%= asEntity('User') %>"
 }
diff --git a/generators/server/templates/src/main/resources/config/couchmove/changelog/V0.1__initial_setup/user__user.json.ejs b/generators/server/templates/src/main/resources/config/couchmove/changelog/V0.1__initial_setup/user__user.json.ejs
index 030cbd472a..f938cdcb01 100644
--- a/generators/server/templates/src/main/resources/config/couchmove/changelog/V0.1__initial_setup/user__user.json.ejs
+++ b/generators/server/templates/src/main/resources/config/couchmove/changelog/V0.1__initial_setup/user__user.json.ejs
@@ -13,5 +13,5 @@
     "authorities": [
         "ROLE_USER"
     ],
-    "_class": "<%=packageName%>.domain.User"
+    "_class": "<%=packageName%>.domain.<%= asEntity('User') %>"
 }
diff --git a/generators/server/templates/src/main/resources/config/couchmove/changelog/V0__create_indexes.n1ql.ejs b/generators/server/templates/src/main/resources/config/couchmove/changelog/V0__create_indexes.n1ql.ejs
index 8315128bd1..c986736415 100644
--- a/generators/server/templates/src/main/resources/config/couchmove/changelog/V0__create_indexes.n1ql.ejs
+++ b/generators/server/templates/src/main/resources/config/couchmove/changelog/V0__create_indexes.n1ql.ejs
@@ -4,7 +4,7 @@ CREATE INDEX type ON `${bucket}`(`_class`)
 <%_ if (!skipUserManagement) { _%>
 
 CREATE INDEX user_mail ON `${bucket}`(email)
-    WHERE `_class` = "<%=packageName%>.domain.User"
+    WHERE `_class` = "<%=packageName%>.domain.<%= asEntity('User') %>"
     WITH { "defer_build" : true };
 
 CREATE INDEX audit_event ON `${bucket}`(principal, event_date, event_type)


Test patch:
diff --git a/generators/client/templates/angular/src/test/javascript/jest.conf.js.ejs b/generators/client/templates/angular/src/test/javascript/jest.conf.js.ejs
index 37f77aa1ab..96da9d93dd 100644
--- a/generators/client/templates/angular/src/test/javascript/jest.conf.js.ejs
+++ b/generators/client/templates/angular/src/test/javascript/jest.conf.js.ejs
@@ -16,7 +16,7 @@ module.exports = {
     },
     reporters: [
         'default',
-        [ 'jest-junit', { output: './<%= BUILD_DIR %>test-results/jest/TESTS-results.xml' } ]
+        [ 'jest-junit', { output: './<%= BUILD_DIR %>test-results/TESTS-results-jest.xml' } ]
     ],
     testResultsProcessor: 'jest-sonar-reporter',
     transformIgnorePatterns: ['node_modules/(?!@angular/common/locales)'],
diff --git a/generators/client/templates/react/src/test/javascript/jest.conf.js.ejs b/generators/client/templates/react/src/test/javascript/jest.conf.js.ejs
index d3411999b9..4b792d4470 100644
--- a/generators/client/templates/react/src/test/javascript/jest.conf.js.ejs
+++ b/generators/client/templates/react/src/test/javascript/jest.conf.js.ejs
@@ -16,7 +16,7 @@ module.exports = {
   },
   reporters: [
     'default',
-    [ 'jest-junit', { output: './<%= BUILD_DIR %>test-results/jest/TESTS-results.xml' } ]
+    [ 'jest-junit', { output: './<%= BUILD_DIR %>test-results/TESTS-results-jest.xml' } ]
   ],
   testResultsProcessor: 'jest-sonar-reporter',
   testPathIgnorePatterns: [
diff --git a/generators/entity-server/templates/src/test/java/package/web/rest/EntityResourceIntTest.java.ejs b/generators/entity-server/templates/src/test/java/package/web/rest/EntityResourceIntTest.java.ejs
index 48a9fe4cc9..848d307c7b 100644
--- a/generators/entity-server/templates/src/test/java/package/web/rest/EntityResourceIntTest.java.ejs
+++ b/generators/entity-server/templates/src/test/java/package/web/rest/EntityResourceIntTest.java.ejs
@@ -23,12 +23,12 @@ import <%=packageName%>.<%= mainClass %>;
 <% if (authenticationType === 'uaa') { %>
 import <%=packageName%>.config.SecurityBeanOverrideConfiguration;
 <% } %>
-import <%=packageName%>.domain.<%= entityClass %>;
+import <%=packageName%>.domain.<%= asEntity(entityClass) %>;
 <%_ for (idx in relationships) { // import entities in required relationships
         const relationshipValidate = relationships[idx].relationshipValidate;
         const otherEntityNameCapitalized = relationships[idx].otherEntityNameCapitalized;
         if ((relationshipValidate !== null && relationshipValidate === true) || jpaMetamodelFiltering) { _%>
-import <%=packageName%>.domain.<%= otherEntityNameCapitalized %>;
+import <%=packageName%>.domain.<%= asEntity(otherEntityNameCapitalized) %>;
 <%_ } } _%>
 <%_ if (saveUserSnapshot) { _%>
 import <%=packageName%>.repository.UserRepository;
@@ -43,7 +43,7 @@ import <%=packageName%>.service.<%= entityClass %>Service;
 import <%=packageName%>.repository.reactive.<%= entityClass %>ReactiveRepository;
 <%_ } _%>
 <%_ if (dto === 'mapstruct') { _%>
-import <%=packageName%>.service.dto.<%= entityClass %>DTO;
+import <%=packageName%>.service.dto.<%= asDto(entityClass) %>;
 import <%=packageName%>.service.mapper.<%= entityClass %>Mapper;
 <%_ } _%>
 import <%=packageName%>.web.rest.errors.ExceptionTranslator;
@@ -350,7 +350,7 @@ _%>
 
     private MockMvc rest<%= entityClass %>MockMvc;
 
-    private <%= entityClass %> <%= entityInstance %>;
+    private <%= asEntity(entityClass) %> <%= asEntity(entityInstance) %>;
 
     @Before
     public void setup() {
@@ -374,17 +374,17 @@ _%>
      * 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 <%= entityClass %> createEntity(<% if (databaseType === 'sql') { %>EntityManager em<% } %>) {
+    public static <%= asEntity(entityClass) %> createEntity(<% if (databaseType === 'sql') { %>EntityManager em<% } %>) {
         <%_ if (fluentMethods) { _%>
-        <%= entityClass %> <%= entityInstance %> = new <%= entityClass %>()<% for (idx in fields) { %>
+        <%= asEntity(entityClass) %> <%= asEntity(entityInstance) %> = new <%= asEntity(entityClass) %>()<% for (idx in fields) { %>
             .<%= fields[idx].fieldName %>(<%='DEFAULT_' + fields[idx].fieldNameUnderscored.toUpperCase()%>)<% if ((fields[idx].fieldType === 'byte[]' || fields[idx].fieldType === 'ByteBuffer') && fields[idx].fieldTypeBlobContent !== 'text') { %>
             .<%= fields[idx].fieldName %>ContentType(<%='DEFAULT_' + fields[idx].fieldNameUnderscored.toUpperCase()%>_CONTENT_TYPE)<% } %><% } %>;
         <%_ } else { _%>
-        <%= entityClass %> <%= entityInstance %> = new <%= entityClass %>();
+        <%= asEntity(entityClass) %> <%= asEntity(entityInstance) %> = new <%= asEntity(entityClass) %>();
             <%_ for (idx in fields) { _%>
-        <%= entityInstance %>.set<%= fields[idx].fieldInJavaBeanMethod %>(<%='DEFAULT_' + fields[idx].fieldNameUnderscored.toUpperCase() %>);
+        <%= asEntity(entityInstance) %>.set<%= fields[idx].fieldInJavaBeanMethod %>(<%='DEFAULT_' + fields[idx].fieldNameUnderscored.toUpperCase() %>);
                 <%_ if ((fields[idx].fieldType === 'byte[]' || fields[idx].fieldType === 'ByteBuffer') && fields[idx].fieldTypeBlobContent !== 'text') { _%>
-        <%= entityInstance %>.set<%= fields[idx].fieldInJavaBeanMethod %>ContentType(<%='DEFAULT_' + fields[idx].fieldNameUnderscored.toUpperCase() %>_CONTENT_TYPE);
+        <%= asEntity(entityInstance) %>.set<%= fields[idx].fieldInJavaBeanMethod %>ContentType(<%='DEFAULT_' + fields[idx].fieldNameUnderscored.toUpperCase() %>_CONTENT_TYPE);
                 <%_ } _%>
             <%_ } _%>
         <%_ } _%>
@@ -400,7 +400,7 @@ _%>
             if (relationshipValidate !== null && relationshipValidate === true) { _%>
         // Add required entity
             <%_ if (alreadyGeneratedEntities.indexOf(otherEntityName) == -1) { _%>
-        <%= otherEntityNameCapitalized %> <%= otherEntityName %> = <%= otherEntityNameCapitalized %>ResourceIntTest.createEntity(<% if (databaseType === 'sql') { %>em<% } %>);
+        <%= asEntity(otherEntityNameCapitalized) %> <%= otherEntityName %> = <%= otherEntityNameCapitalized %>ResourceIntTest.createEntity(<% if (databaseType === 'sql') { %>em<% } %>);
                 <%_ if (databaseType === 'sql') { _%>
         em.persist(<%= otherEntityName %>);
         em.flush();
@@ -410,13 +410,13 @@ _%>
                 <%_ } _%>
             <%_ } _%>
             <%_ if (relationshipType === 'many-to-many' || relationshipType === 'one-to-many') { _%>
-        <%= entityInstance %>.get<%= relationshipNameCapitalizedPlural %>().add(<%= otherEntityName %>);
+        <%= asEntity(entityInstance) %>.get<%= relationshipNameCapitalizedPlural %>().add(<%= otherEntityName %>);
             <%_ } else { _%>
-        <%= entityInstance %>.set<%= relationshipNameCapitalized %>(<%= otherEntityName %>);
+        <%= asEntity(entityInstance) %>.set<%= relationshipNameCapitalized %>(<%= otherEntityName %>);
             <%_ } _%>
         <%_ alreadyGeneratedEntities.push(otherEntityName) _%>
         <%_ } } _%>
-        return <%= entityInstance %>;
+        return <%= asEntity(entityInstance) %>;
     }
 
     @Before
@@ -427,7 +427,7 @@ _%>
         <%_ if (databaseType === 'mongodb' || databaseType === 'couchbase' || databaseType === 'cassandra') { _%>
         <%= entityInstance %>Repository.deleteAll();
         <%_ } _%>
-        <%= entityInstance %> = createEntity(<% if (databaseType === 'sql') { %>em<% } %>);
+        <%= asEntity(entityInstance) %> = createEntity(<% if (databaseType === 'sql') { %>em<% } %>);
     }
 
     @Test<% if (databaseType === 'sql') { %>
@@ -437,17 +437,17 @@ _%>
 
         // Create the <%= entityClass %>
         <%_ if (dto === 'mapstruct') { _%>
-        <%= entityClass %>DTO <%= entityInstance %>DTO = <%= entityInstance %>Mapper.toDto(<%= entityInstance %>);
+        <%= asDto(entityClass) %> <%= asDto(entityInstance) %> = <%= entityInstance %>Mapper.toDto(<%= asEntity(entityInstance) %>);
         <%_ } _%>
         rest<%= entityClass %>MockMvc.perform(post("/api/<%= entityApiUrl %>")
             .contentType(TestUtil.APPLICATION_JSON_UTF8)
-            .content(TestUtil.convertObjectToJsonBytes(<%= entityInstance %><% if (dto === 'mapstruct') { %>DTO<% } %>)))
+            .content(TestUtil.convertObjectToJsonBytes(<%=(dto === 'mapstruct' ? asDto(entityInstance) : asEntity(entityInstance))%>)))
             .andExpect(status().isCreated());
 
         // Validate the <%= entityClass %> in the database
-        List<<%= entityClass %>> <%= entityInstance %>List = <%= entityInstance %>Repository.findAll();
+        List<<%= asEntity(entityClass) %>> <%= entityInstance %>List = <%= entityInstance %>Repository.findAll();
         assertThat(<%= entityInstance %>List).hasSize(databaseSizeBeforeCreate + 1);
-        <%= entityClass %> test<%= entityClass %> = <%= entityInstance %>List.get(<%= entityInstance %>List.size() - 1);
+        <%= asEntity(entityClass) %> test<%= entityClass %> = <%= entityInstance %>List.get(<%= entityInstance %>List.size() - 1);
         <%_ for (idx in fields) { if (fields[idx].fieldType === 'ZonedDateTime') { _%>
         assertThat(test<%= entityClass %>.get<%=fields[idx].fieldInJavaBeanMethod%>()).isEqualTo(<%='DEFAULT_' + fields[idx].fieldNameUnderscored.toUpperCase()%>);
         <%_ } else if ((fields[idx].fieldType === 'byte[]' || fields[idx].fieldType === 'ByteBuffer') && fields[idx].fieldTypeBlobContent !== 'text') { _%>
@@ -471,24 +471,24 @@ _%>
         int databaseSizeBeforeCreate = <%= entityInstance %>Repository.findAll().size();
 
         // Create the <%= entityClass %> with an existing ID
-        <%= entityInstance %>.setId(<% if (databaseType === 'sql') { %>1L<% } else if (databaseType === 'mongodb' || databaseType === 'couchbase') { %>"existing_id"<% } else if (databaseType === 'cassandra') { %>UUID.randomUUID()<% } %>);
+        <%= asEntity(entityInstance) %>.setId(<% if (databaseType === 'sql') { %>1L<% } else if (databaseType === 'mongodb' || databaseType === 'couchbase') { %>"existing_id"<% } else if (databaseType === 'cassandra') { %>UUID.randomUUID()<% } %>);
         <%_ if (dto === 'mapstruct') { _%>
-        <%= entityClass %>DTO <%= entityInstance %>DTO = <%= entityInstance %>Mapper.toDto(<%= entityInstance %>);
+        <%= asDto(entityClass) %> <%= asDto(entityInstance) %> = <%= entityInstance %>Mapper.toDto(<%= asEntity(entityInstance) %>);
         <%_ } _%>
 
         // An entity with an existing ID cannot be created, so this API call must fail
         rest<%= entityClass %>MockMvc.perform(post("/api/<%= entityApiUrl %>")
             .contentType(TestUtil.APPLICATION_JSON_UTF8)
-            .content(TestUtil.convertObjectToJsonBytes(<%= entityInstance %><% if (dto === 'mapstruct') { %>DTO<% } %>)))
+            .content(TestUtil.convertObjectToJsonBytes(<%=(dto === 'mapstruct' ? asDto(entityInstance) : asEntity(entityInstance))%>)))
             .andExpect(status().isBadRequest());
 
         // Validate the <%= entityClass %> in the database
-        List<<%= entityClass %>> <%= entityInstance %>List = <%= entityInstance %>Repository.findAll();
+        List<<%= asEntity(entityClass) %>> <%= entityInstance %>List = <%= entityInstance %>Repository.findAll();
         assertThat(<%= entityInstance %>List).hasSize(databaseSizeBeforeCreate);
         <%_ if (searchEngine === 'elasticsearch') { _%>
 
         // Validate the <%= entityClass %> in Elasticsearch
-        verify(mock<%= entityClass %>SearchRepository, times(0)).save(<%= entityInstance %>);
+        verify(mock<%= entityClass %>SearchRepository, times(0)).save(<%= asEntity(entityInstance) %>);
         <%_ } _%>
     }
 <% for (idx in fields) { %><% if (fields[idx].fieldValidate === true) {
@@ -502,17 +502,17 @@ _%>
     public void check<%= fields[idx].fieldInJavaBeanMethod %>IsRequired() throws Exception {
         int databaseSizeBeforeTest = <%= entityInstance %>Repository.findAll().size();
         // set the field null
-        <%= entityInstance %>.set<%= fields[idx].fieldInJavaBeanMethod %>(null);
+        <%= asEntity(entityInstance) %>.set<%= fields[idx].fieldInJavaBeanMethod %>(null);
 
         // Create the <%= entityClass %>, which fails.<% if (dto === 'mapstruct') { %>
-        <%= entityClass %>DTO <%= entityInstance %>DTO = <%= entityInstance %>Mapper.toDto(<%= entityInstance %>);<% } %>
+        <%= asDto(entityClass) %> <%= asDto(entityInstance) %> = <%= entityInstance %>Mapper.toDto(<%= asEntity(entityInstance) %>);<% } %>
 
         rest<%= entityClass %>MockMvc.perform(post("/api/<%= entityApiUrl %>")
             .contentType(TestUtil.APPLICATION_JSON_UTF8)
-            .content(TestUtil.convertObjectToJsonBytes(<%= entityInstance %><% if (dto === 'mapstruct') { %>DTO<% } %>)))
+            .content(TestUtil.convertObjectToJsonBytes(<%=(dto === 'mapstruct' ? asDto(entityInstance) : asEntity(entityInstance))%>)))
             .andExpect(status().isBadRequest());
 
-        List<<%= entityClass %>> <%= entityInstance %>List = <%= entityInstance %>Repository.findAll();
+        List<<%= asEntity(entityClass) %>> <%= entityInstance %>List = <%= entityInstance %>Repository.findAll();
         assertThat(<%= entityInstance %>List).hasSize(databaseSizeBeforeTest);
     }
 <%  } } } %>
@@ -521,17 +521,17 @@ _%>
     public void getAll<%= entityClassPlural %>() throws Exception {
         // Initialize the database
         <%_ if (databaseType === 'cassandra') { _%>
-        <%= entityInstance %>.setId(UUID.randomUUID());
+        <%= asEntity(entityInstance) %>.setId(UUID.randomUUID());
         <%_ } _%>
-        <%= entityInstance %>Repository.save<% if (databaseType === 'sql') { %>AndFlush<% } %>(<%= entityInstance %>);
+        <%= entityInstance %>Repository.save<% if (databaseType === 'sql') { %>AndFlush<% } %>(<%= asEntity(entityInstance) %>);
 
         // Get all the <%= entityInstance %>List
         rest<%= entityClass %>MockMvc.perform(get("/api/<%= entityApiUrl %><% if (databaseType !== 'cassandra') { %>?sort=id,desc<% } %>"))
             .andExpect(status().isOk())
             .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))<% if (databaseType === 'sql') { %>
-            .andExpect(jsonPath("$.[*].id").value(hasItem(<%= entityInstance %>.getId().intValue())))<% } %><% if (databaseType === 'mongodb' || databaseType === 'couchbase') { %>
-            .andExpect(jsonPath("$.[*].id").value(hasItem(<%= entityInstance %>.getId())))<% } %><% if (databaseType === 'cassandra') { %>
-            .andExpect(jsonPath("$.[*].id").value(hasItem(<%= entityInstance %>.getId().toString())))<% } %><% for (idx in fields) {%>
+            .andExpect(jsonPath("$.[*].id").value(hasItem(<%= asEntity(entityInstance) %>.getId().intValue())))<% } %><% if (databaseType === 'mongodb' || databaseType === 'couchbase') { %>
+            .andExpect(jsonPath("$.[*].id").value(hasItem(<%= asEntity(entityInstance) %>.getId())))<% } %><% if (databaseType === 'cassandra') { %>
+            .andExpect(jsonPath("$.[*].id").value(hasItem(<%= asEntity(entityInstance) %>.getId().toString())))<% } %><% for (idx in fields) {%>
             <%_ if ((fields[idx].fieldType === 'byte[]' || fields[idx].fieldType === 'ByteBuffer') && fields[idx].fieldTypeBlobContent !== 'text') { _%>
             .andExpect(jsonPath("$.[*].<%=fields[idx].fieldName%>ContentType").value(hasItem(<%='DEFAULT_' + fields[idx].fieldNameUnderscored.toUpperCase()%>_CONTENT_TYPE)))
             <%_ } _%>
@@ -595,17 +595,17 @@ _%>
     public void get<%= entityClass %>() throws Exception {
         // Initialize the database
         <%_ if (databaseType === 'cassandra') { _%>
-        <%= entityInstance %>.setId(UUID.randomUUID());
+        <%= asEntity(entityInstance) %>.setId(UUID.randomUUID());
         <%_ } _%>
-        <%= entityInstance %>Repository.save<% if (databaseType === 'sql') { %>AndFlush<% } %>(<%= entityInstance %>);
+        <%= entityInstance %>Repository.save<% if (databaseType === 'sql') { %>AndFlush<% } %>(<%= asEntity(entityInstance) %>);
 
         // Get the <%= entityInstance %>
-        rest<%= entityClass %>MockMvc.perform(get("/api/<%= entityApiUrl %>/{id}", <%= entityInstance %>.getId()))
+        rest<%= entityClass %>MockMvc.perform(get("/api/<%= entityApiUrl %>/{id}", <%= asEntity(entityInstance) %>.getId()))
             .andExpect(status().isOk())
             .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))<% if (databaseType === 'sql') { %>
-            .andExpect(jsonPath("$.id").value(<%= entityInstance %>.getId().intValue()))<% } %><% if (databaseType === 'mongodb' || databaseType === 'couchbase') { %>
-            .andExpect(jsonPath("$.id").value(<%= entityInstance %>.getId()))<% } %><% if (databaseType === 'cassandra') { %>
-            .andExpect(jsonPath("$.id").value(<%= entityInstance %>.getId().toString()))<% } %><% for (idx in fields) {%>
+            .andExpect(jsonPath("$.id").value(<%= asEntity(entityInstance) %>.getId().intValue()))<% } %><% if (databaseType === 'mongodb' || databaseType === 'couchbase') { %>
+            .andExpect(jsonPath("$.id").value(<%= asEntity(entityInstance) %>.getId()))<% } %><% if (databaseType === 'cassandra') { %>
+            .andExpect(jsonPath("$.id").value(<%= asEntity(entityInstance) %>.getId().toString()))<% } %><% for (idx in fields) {%>
             <%_ if ((fields[idx].fieldType === 'byte[]' || fields[idx].fieldType === 'ByteBuffer') && fields[idx].fieldTypeBlobContent !== 'text') { _%>
             .andExpect(jsonPath("$.<%=fields[idx].fieldName%>ContentType").value(<%='DEFAULT_' + fields[idx].fieldNameUnderscored.toUpperCase()%>_CONTENT_TYPE))
             <%_ } _%>
@@ -621,7 +621,7 @@ _%>
     @Transactional<% } %>
     public void getAll<%= entityClassPlural %>By<%= searchBy.fieldInJavaBeanMethod %>IsEqualToSomething() throws Exception {
         // Initialize the database
-        <%= entityInstance %>Repository.saveAndFlush(<%= entityInstance %>);
+        <%= entityInstance %>Repository.saveAndFlush(<%= asEntity(entityInstance) %>);
 
         // Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> equals to <%='DEFAULT_' + searchBy.fieldNameUnderscored.toUpperCase()%>
         default<%= entityClass %>ShouldBeFound("<%= searchBy.fieldName %>.equals=" + <%='DEFAULT_' + searchBy.fieldNameUnderscored.toUpperCase()%>);
@@ -634,7 +634,7 @@ _%>
     @Transactional<% } %>
     public void getAll<%= entityClassPlural %>By<%= searchBy.fieldInJavaBeanMethod %>IsInShouldWork() throws Exception {
         // Initialize the database
-        <%= entityInstance %>Repository.saveAndFlush(<%= entityInstance %>);
+        <%= entityInstance %>Repository.saveAndFlush(<%= asEntity(entityInstance) %>);
 
         // 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()%>);
@@ -647,7 +647,7 @@ _%>
     @Transactional<% } %>
     public void getAll<%= entityClassPlural %>By<%= searchBy.fieldInJavaBeanMethod %>IsNullOrNotNull() throws Exception {
         // Initialize the database
-        <%= entityInstance %>Repository.saveAndFlush(<%= entityInstance %>);
+        <%= entityInstance %>Repository.saveAndFlush(<%= asEntity(entityInstance) %>);
 
         // Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> is not null
         default<%= entityClass %>ShouldBeFound("<%= searchBy.fieldName %>.specified=true");
@@ -671,7 +671,7 @@ _%>
     @Transactional<% } %>
     public void getAll<%= entityClassPlural %>By<%= searchBy.fieldInJavaBeanMethod %>IsGreaterThanOrEqualToSomething() throws Exception {
         // Initialize the database
-        <%= entityInstance %>Repository.saveAndFlush(<%= entityInstance %>);
+        <%= entityInstance %>Repository.saveAndFlush(<%= asEntity(entityInstance) %>);
 
         // Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> greater than or equals to <%= defaultValue %>
         default<%= entityClass %>ShouldBeFound("<%= searchBy.fieldName %>.greaterOrEqualThan=" + <%= defaultValue %>);
@@ -684,7 +684,7 @@ _%>
     @Transactional<% } %>
     public void getAll<%= entityClassPlural %>By<%= searchBy.fieldInJavaBeanMethod %>IsLessThanSomething() throws Exception {
         // Initialize the database
-        <%= entityInstance %>Repository.saveAndFlush(<%= entityInstance %>);
+        <%= entityInstance %>Repository.saveAndFlush(<%= asEntity(entityInstance) %>);
 
         // Get all the <%= entityInstance %>List where <%= searchBy.fieldName %> less than or equals to <%= defaultValue %>
         default<%= entityClass %>ShouldNotBeFound("<%= searchBy.fieldName %>.lessThan=" + <%= defaultValue %>);
@@ -701,18 +701,18 @@ _%>
     @Transactional<% } %>
     public void getAll<%= entityClassPlural %>By<%= relationship.relationshipNameCapitalized %>IsEqualToSomething() throws Exception {
         // Initialize the database
-        <%= relationship.otherEntityNameCapitalized %> <%= relationship.relationshipFieldName %> = <%= relationship.otherEntityNameCapitalized %>ResourceIntTest.createEntity(em);
+        <%= asEntity(relationship.otherEntityNameCapitalized) %> <%= relationship.relationshipFieldName %> = <%= relationship.otherEntityNameCapitalized %>ResourceIntTest.createEntity(em);
         em.persist(<%= relationship.relationshipFieldName %>);
         em.flush();
 <%_ if (relationship.relationshipType === 'many-to-many' || relationship.relationshipType === 'one-to-many') { _%>
-        <%= entityInstance %>.add<%= relationship.relationshipNameCapitalized %>(<%= relationship.relationshipFieldName %>);
+        <%= asEntity(entityInstance) %>.add<%= relationship.relationshipNameCapitalized %>(<%= relationship.relationshipFieldName %>);
 <%_ } else { _%>
-        <%= entityInstance %>.set<%= relationship.relationshipNameCapitalized %>(<%= relationship.relationshipFieldName %>);
+        <%= asEntity(entityInstance) %>.set<%= relationship.relationshipNameCapitalized %>(<%= relationship.relationshipFieldName %>);
 <%_     if (relationship.ownerSide === false) { _%>
-        <%= relationship.relationshipFieldName %>.set<%= relationship.otherEntityRelationshipNameCapitalized %>(<%= entityInstance %>);
+        <%= relationship.relationshipFieldName %>.set<%= relationship.otherEntityRelationshipNameCapitalized %>(<%= asEntity(entityInstance) %>);
 <%_     } _%>
 <%_ } _%>
-        <%= entityInstance %>Repository.saveAndFlush(<%= entityInstance %>);
+        <%= entityInstance %>Repository.saveAndFlush(<%= asEntity(entityInstance) %>);
         <% if (authenticationType === 'oauth2' && relationship.relationshipFieldName === 'user') { _%>String<%_ } else { _%>Long<% } %> <%= relationship.relationshipFieldName %>Id = <%= relationship.relationshipFieldName %>.getId();
 
         // Get all the <%= entityInstance %>List where <%= relationship.relationshipFieldName %> equals to <%= relationship.relationshipFieldName %>Id
@@ -730,7 +730,7 @@ _%>
         rest<%= entityClass %>MockMvc.perform(get("/api/<%= entityApiUrl %>?sort=id,desc&" + filter))
             .andExpect(status().isOk())
             .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
-            .andExpect(jsonPath("$.[*].id").value(hasItem(<%= entityInstance %>.getId().intValue())))<% fields.forEach((field) => { %>
+            .andExpect(jsonPath("$.[*].id").value(hasItem(<%= asEntity(entityInstance) %>.getId().intValue())))<% fields.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)))
             <%_ } _%>
@@ -767,9 +767,9 @@ _%>
     public void getAll<%= entityClassPlural %>AsStream() {
         // Initialize the database
         <%_ if (databaseType === 'cassandra') { _%>
-        <%= entityInstance %>.setId(UUID.randomUUID());
+        <%= asEntity(entityInstance) %>.setId(UUID.randomUUID());
         <%_ } _%>
-        <%= entityInstance %>Repository.save(<%= entityInstance %>);
+        <%= entityInstance %>Repository.save(<%= asEntity(entityInstance) %>);
 
         <%_ if (service !== 'no') { _%>
         final <%= entityClass %>Resource <%= entityInstance %>Resource = new <%= entityClass %>Resource(<%= entityInstance %>Service<% if (jpaMetamodelFiltering) { %>, <%= entityInstance %>QueryService<% } %>);
@@ -781,18 +781,18 @@ _%>
         List<<%= entityClass %>> <%= entityInstance %>List = client.get().uri("/api/<%= entityApiUrl %>").accept(MediaType.APPLICATION_STREAM_JSON).exchange()
             .expectStatus().isOk()
             .expectHeader().contentTypeCompatibleWith(MediaType.APPLICATION_STREAM_JSON)
-            .returnResult(<%= entityClass %><% if (dto !== 'no') { %>DTO<% } %>.class)
+            .returnResult(<%=(dto !== 'no' ? asDto(entityInstance) : asEntity(entityInstance))%>.class)
             .getResponseBody()
             <%_ if (dto !== 'no') { _%>
             .map(<%= entityInstance %>Mapper::toEntity)
             <%_ } _%>
-            .filter(<%= entityInstance %>::equals)
+            .filter(<%= asEntity(entityInstance) %>::equals)
             .collectList()
             .block(Duration.ofSeconds(5));
 
         assertThat(<%= entityInstance %>List).isNotNull();
         assertThat(<%= entityInstance %>List).hasSize(1);
-        <%= entityClass %> test<%= entityClass %> = <%= entityInstance %>List.get(0);
+        <%= asEntity(entityClass) %> test<%= entityClass %> = <%= entityInstance %>List.get(0);
         <%_ for (idx in fields) { if (fields[idx].fieldType === 'ZonedDateTime') { _%>
         assertThat(test<%= entityClass %>.get<%=fields[idx].fieldInJavaBeanMethod%>()).isEqualTo(<%='DEFAULT_' + fields[idx].fieldNameUnderscored.toUpperCase()%>);
         <%_ } else if ((fields[idx].fieldType === 'byte[]' || fields[idx].fieldType === 'ByteBuffer') && fields[idx].fieldTypeBlobContent !== 'text') { _%>
@@ -819,49 +819,49 @@ _%>
     public void update<%= entityClass %>() throws Exception {
         // Initialize the database
         <%_ if (databaseType === 'cassandra') { _%>
-        <%= entityInstance %>.setId(UUID.randomUUID());
+        <%= asEntity(entityInstance) %>.setId(UUID.randomUUID());
         <%_ } _%>
 <%_ if (service !== 'no' && dto !== 'mapstruct') { _%>
-        <%= entityInstance %>Service.save(<%= entityInstance %>);
+        <%= entityInstance %>Service.save(<%= asEntity(entityInstance) %>);
     <%_ if (searchEngine === 'elasticsearch') { _%>
         // As the test used the service layer, reset the Elasticsearch mock repository
         reset(mock<%= entityClass %>SearchRepository);
     <%_ } _%>
 <%_ } else { _%>
-        <%= entityInstance %>Repository.save<% if (databaseType === 'sql') { %>AndFlush<% } %>(<%= entityInstance %>);
+        <%= entityInstance %>Repository.save<% if (databaseType === 'sql') { %>AndFlush<% } %>(<%= asEntity(entityInstance) %>);
 <%_ } _%>
 
         int databaseSizeBeforeUpdate = <%= entityInstance %>Repository.findAll().size();
 
         // Update the <%= entityInstance %>
-        <%= entityClass %> updated<%= entityClass %> = <%= entityInstance %>Repository.findById(<%= entityInstance %>.getId()).get();<% if (databaseType === 'sql') { %>
-        // Disconnect from session so that the updates on updated<%= entityClass %> are not directly saved in db
-        em.detach(updated<%= entityClass %>);<% } %>
+        <%= asEntity(entityClass) %> updated<%= asEntity(entityClass) %> = <%= entityInstance %>Repository.findById(<%= asEntity(entityInstance) %>.getId()).get();<% if (databaseType === 'sql') { %>
+        // Disconnect from session so that the updates on updated<%= asEntity(entityClass) %> are not directly saved in db
+        em.detach(updated<%= asEntity(entityClass) %>);<% } %>
         <%_ if (fluentMethods && fields.length > 0) { _%>
-        updated<%= entityClass %><% for (idx in fields) { %>
+        updated<%= asEntity(entityClass) %><% for (idx in fields) { %>
             .<%= fields[idx].fieldName %>(<%='UPDATED_' + fields[idx].fieldNameUnderscored.toUpperCase()%>)<% if ((fields[idx].fieldType === 'byte[]' || fields[idx].fieldType === 'ByteBuffer') && fields[idx].fieldTypeBlobContent !== 'text') { %>
             .<%= fields[idx].fieldName %>ContentType(<%='UPDATED_' + fields[idx].fieldNameUnderscored.toUpperCase()%>_CONTENT_TYPE)<% } %><% } %>;
         <%_ } else { _%>
             <%_ for (idx in fields) { _%>
-        updated<%= entityClass %>.set<%= fields[idx].fieldInJavaBeanMethod %>(<%='UPDATED_' + fields[idx].fieldNameUnderscored.toUpperCase()%>);
+        updated<%= asEntity(entityClass) %>.set<%= fields[idx].fieldInJavaBeanMethod %>(<%='UPDATED_' + fields[idx].fieldNameUnderscored.toUpperCase()%>);
                 <%_ if ((fields[idx].fieldType === 'byte[]' || fields[idx].fieldType === 'ByteBuffer') && fields[idx].fieldTypeBlobContent !== 'text') { _%>
-        updated<%= entityClass %>.set<%= fields[idx].fieldInJavaBeanMethod %>ContentType(<%='UPDATED_' + fields[idx].fieldNameUnderscored.toUpperCase()%>_CONTENT_TYPE);
+        updated<%= asEntity(entityClass) %>.set<%= fields[idx].fieldInJavaBeanMethod %>ContentType(<%='UPDATED_' + fields[idx].fieldNameUnderscored.toUpperCase()%>_CONTENT_TYPE);
                 <%_ } _%>
             <%_ } _%>
         <%_ } _%>
         <%_ if (dto === 'mapstruct') { _%>
-        <%= entityClass %>DTO <%= entityInstance %>DTO = <%= entityInstance %>Mapper.toDto(updated<%= entityClass %>);
+        <%= asDto(entityClass) %> <%= asDto(entityInstance) %> = <%= entityInstance %>Mapper.toDto(updated<%= asEntity(entityClass) %>);
         <%_ } _%>
 
         rest<%= entityClass %>MockMvc.perform(put("/api/<%= entityApiUrl %>")
             .contentType(TestUtil.APPLICATION_JSON_UTF8)
-            .content(TestUtil.convertObjectToJsonBytes(<% if (dto === 'mapstruct') { %><%= entityInstance %>DTO<% } else { %>updated<%= entityClass %><% } %>)))
+            .content(TestUtil.convertObjectToJsonBytes(<%=(dto === 'mapstruct' ? asDto(entityInstance) : 'updated' + asEntity(entityClass))%>)))
             .andExpect(status().isOk());
 
         // Validate the <%= entityClass %> in the database
-        List<<%= entityClass %>> <%= entityInstance %>List = <%= entityInstance %>Repository.findAll();
+        List<<%= asEntity(entityClass) %>> <%= entityInstance %>List = <%= entityInstance %>Repository.findAll();
         assertThat(<%= entityInstance %>List).hasSize(databaseSizeBeforeUpdate);
-        <%= entityClass %> test<%= entityClass %> = <%= entityInstance %>List.get(<%= entityInstance %>List.size() - 1);
+        <%= asEntity(entityClass) %> test<%= entityClass %> = <%= entityInstance %>List.get(<%= entityInstance %>List.size() - 1);
         <%_ for (idx in fields) { if (fields[idx].fieldType === 'ZonedDateTime') { _%>
         assertThat(test<%= entityClass %>.get<%=fields[idx].fieldInJavaBeanMethod%>()).isEqualTo(<%='UPDATED_' + fields[idx].fieldNameUnderscored.toUpperCase()%>);
         <%_ } else if ((fields[idx].fieldType === 'byte[]' || fields[idx].fieldType === 'ByteBuffer') && fields[idx].fieldTypeBlobContent !== 'text') { _%>
@@ -885,21 +885,21 @@ _%>
         int databaseSizeBeforeUpdate = <%= entityInstance %>Repository.findAll().size();
 
         // Create the <%= entityClass %><% if (dto === 'mapstruct') { %>
-        <%= entityClass %>DTO <%= entityInstance %>DTO = <%= entityInstance %>Mapper.toDto(<%= entityInstance %>);<% } %>
+        <%= asDto(entityClass) %> <%= asDto(entityInstance) %> = <%= entityInstance %>Mapper.toDto(<%= asEntity(entityInstance) %>);<% } %>
 
         // If the entity doesn't have an ID, it will throw BadRequestAlertException
         rest<%= entityClass %>MockMvc.perform(put("/api/<%= entityApiUrl %>")
             .contentType(TestUtil.APPLICATION_JSON_UTF8)
-            .content(TestUtil.convertObjectToJsonBytes(<%= entityInstance %><% if (dto === 'mapstruct') { %>DTO<% } %>)))
+            .content(TestUtil.convertObjectToJsonBytes(<%=(dto === 'mapstruct' ? asDto(entityInstance) : asEntity(entityInstance))%>)))
             .andExpect(status().isBadRequest());
 
         // Validate the <%= entityClass %> in the database
-        List<<%= entityClass %>> <%= entityInstance %>List = <%= entityInstance %>Repository.findAll();
+        List<<%= asEntity(entityClass) %>> <%= entityInstance %>List = <%= entityInstance %>Repository.findAll();
         assertThat(<%= entityInstance %>List).hasSize(databaseSizeBeforeUpdate);
         <%_ if (searchEngine === 'elasticsearch') { _%>
 
         // Validate the <%= entityClass %> in Elasticsearch
-        verify(mock<%= entityClass %>SearchRepository, times(0)).save(<%= entityInstance %>);
+        verify(mock<%= entityClass %>SearchRepository, times(0)).save(<%= asEntity(entityInstance) %>);
         <%_ } _%>
     }
 
@@ -908,28 +908,28 @@ _%>
     public void delete<%= entityClass %>() throws Exception {
         // Initialize the database
         <%_ if (databaseType === 'cassandra') { _%>
-        <%= entityInstance %>.setId(UUID.randomUUID());
+        <%= asEntity(entityInstance) %>.setId(UUID.randomUUID());
         <%_ } _%>
 <%_ if (service !== 'no' && dto !== 'mapstruct') { _%>
-        <%= entityInstance %>Service.save(<%= entityInstance %>);
+        <%= entityInstance %>Service.save(<%= asEntity(entityInstance) %>);
 <%_ } else { _%>
-        <%= entityInstance %>Repository.save<% if (databaseType === 'sql') { %>AndFlush<% } %>(<%= entityInstance %>);
+        <%= entityInstance %>Repository.save<% if (databaseType === 'sql') { %>AndFlush<% } %>(<%= asEntity(entityInstance) %>);
 <%_ } _%>
 
         int databaseSizeBeforeDelete = <%= entityInstance %>Repository.findAll().size();
 
         // Delete the <%= entityInstance %>
-        rest<%= entityClass %>MockMvc.perform(delete("/api/<%= entityApiUrl %>/{id}", <%= entityInstance %>.getId())
+        rest<%= entityClass %>MockMvc.perform(delete("/api/<%= entityApiUrl %>/{id}", <%= asEntity(entityInstance) %>.getId())
             .accept(TestUtil.APPLICATION_JSON_UTF8))
             .andExpect(status().isOk());
 
         // Validate the database is empty
-        List<<%= entityClass %>> <%= entityInstance %>List = <%= entityInstance %>Repository.findAll();
+        List<<%= asEntity(entityClass) %>> <%= entityInstance %>List = <%= entityInstance %>Repository.findAll();
         assertThat(<%= entityInstance %>List).hasSize(databaseSizeBeforeDelete - 1);
         <%_ if (searchEngine === 'elasticsearch') { _%>
 
         // Validate the <%= entityClass %> in Elasticsearch
-        verify(mock<%= entityClass %>SearchRepository, times(1)).deleteById(<%= entityInstance %>.getId());
+        verify(mock<%= entityClass %>SearchRepository, times(1)).deleteById(<%= asEntity(entityInstance) %>.getId());
         <%_ } _%>
     }
     <%_ if (searchEngine === 'elasticsearch') { _%>
@@ -939,27 +939,27 @@ _%>
     public void search<%= entityClass %>() throws Exception {
         // Initialize the database
         <%_ if (databaseType === 'cassandra') { _%>
-        <%= entityInstance %>.setId(UUID.randomUUID());
+        <%= asEntity(entityInstance) %>.setId(UUID.randomUUID());
         <%_ } _%>
 <%_ if (service !== 'no' && dto !== 'mapstruct') { _%>
-        <%= entityInstance %>Service.save(<%= entityInstance %>);
+        <%= entityInstance %>Service.save(<%= asEntity(entityInstance) %>);
 <%_ } else { _%>
-        <%= entityInstance %>Repository.save<% if (databaseType === 'sql') { %>AndFlush<% } %>(<%= entityInstance %>);
+        <%= entityInstance %>Repository.save<% if (databaseType === 'sql') { %>AndFlush<% } %>(<%= asEntity(entityInstance) %>);
 <%_ } _%>
 <%_ if (searchEngine === 'elasticsearch' && pagination !== 'no') { _%>
-        when(mock<%= entityClass %>SearchRepository.search(queryStringQuery("id:" + <%= entityInstance %>.getId()), PageRequest.of(0, 20)))
-            .thenReturn(new PageImpl<>(Collections.singletonList(<%= entityInstance %>), PageRequest.of(0, 1), 1));
+        when(mock<%= entityClass %>SearchRepository.search(queryStringQuery("id:" + <%= asEntity(entityInstance) %>.getId()), PageRequest.of(0, 20)))
+            .thenReturn(new PageImpl<>(Collections.singletonList(<%= asEntity(entityInstance) %>), PageRequest.of(0, 1), 1));
 <%_ } else { _%>
-        when(mock<%= entityClass %>SearchRepository.search(queryStringQuery("id:" + <%= entityInstance %>.getId())))
-            .thenReturn(Collections.singletonList(<%= entityInstance %>));
+        when(mock<%= entityClass %>SearchRepository.search(queryStringQuery("id:" + <%= asEntity(entityInstance) %>.getId())))
+            .thenReturn(Collections.singletonList(<%= asEntity(entityInstance) %>));
 <%_ } _%>
         // Search the <%= entityInstance %>
-        rest<%= entityClass %>MockMvc.perform(get("/api/_search/<%= entityApiUrl %>?query=id:" + <%= entityInstance %>.getId()))
+        rest<%= entityClass %>MockMvc.perform(get("/api/_search/<%= entityApiUrl %>?query=id:" + <%= asEntity(entityInstance) %>.getId()))
             .andExpect(status().isOk())
             .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))<% if (databaseType === 'sql') { %>
-            .andExpect(jsonPath("$.[*].id").value(hasItem(<%= entityInstance %>.getId().intValue())))<% } %><% if (databaseType === 'mongodb' || databaseType === 'couchbase') { %>
-            .andExpect(jsonPath("$.[*].id").value(hasItem(<%= entityInstance %>.getId())))<% } %><% if (databaseType === 'cassandra') { %>
-            .andExpect(jsonPath("$.[*].id").value(hasItem(<%= entityInstance %>.getId().toString())))<% } %><% for (idx in fields) {%>
+            .andExpect(jsonPath("$.[*].id").value(hasItem(<%= asEntity(entityInstance) %>.getId().intValue())))<% } %><% if (databaseType === 'mongodb' || databaseType === 'couchbase') { %>
+            .andExpect(jsonPath("$.[*].id").value(hasItem(<%= asEntity(entityInstance) %>.getId())))<% } %><% if (databaseType === 'cassandra') { %>
+            .andExpect(jsonPath("$.[*].id").value(hasItem(<%= asEntity(entityInstance) %>.getId().toString())))<% } %><% for (idx in fields) {%>
             <%_ if ((fields[idx].fieldType === 'byte[]' || fields[idx].fieldType === 'ByteBuffer') && fields[idx].fieldTypeBlobContent !== 'text') { _%>
             .andExpect(jsonPath("$.[*].<%=fields[idx].fieldName%>ContentType").value(hasItem(<%='DEFAULT_' + fields[idx].fieldNameUnderscored.toUpperCase()%>_CONTENT_TYPE)))
             <%_ } _%>
@@ -970,33 +970,33 @@ _%>
     @Test<% if (databaseType === 'sql') { %>
     @Transactional<% } %>
     public void equalsVerifier() throws Exception {
-        TestUtil.equalsVerifier(<%= entityClass %>.class);
-        <%= entityClass %> <%= entityInstance %>1 = new <%= entityClass %>();
-        <%= entityInstance %>1.setId(<% if (databaseType === 'sql') { %>1L<% } else if (databaseType === 'mongodb' || databaseType === 'couchbase') { %>"id1"<% } else if (databaseType === 'cassandra') { %>UUID.randomUUID()<% } %>);
-        <%= entityClass %> <%= entityInstance %>2 = new <%= entityClass %>();
-        <%= entityInstance %>2.setId(<%= entityInstance %>1.getId());
-        assertThat(<%= entityInstance %>1).isEqualTo(<%= entityInstance %>2);
-        <%= entityInstance %>2.setId(<% if (databaseType === 'sql') { %>2L<% } else if (databaseType === 'mongodb' || databaseType === 'couchbase') { %>"id2"<% } else if (databaseType === 'cassandra') { %>UUID.randomUUID()<% } %>);
-        assertThat(<%= entityInstance %>1).isNotEqualTo(<%= entityInstance %>2);
-        <%= entityInstance %>1.setId(null);
-        assertThat(<%= entityInstance %>1).isNotEqualTo(<%= entityInstance %>2);
+        TestUtil.equalsVerifier(<%= asEntity(entityClass) %>.class);
+        <%= asEntity(entityClass) %> <%= asEntity(entityInstance) %>1 = new <%= asEntity(entityClass) %>();
+        <%= asEntity(entityInstance) %>1.setId(<% if (databaseType === 'sql') { %>1L<% } else if (databaseType === 'mongodb' || databaseType === 'couchbase') { %>"id1"<% } else if (databaseType === 'cassandra') { %>UUID.randomUUID()<% } %>);
+        <%= asEntity(entityClass) %> <%= asEntity(entityInstance) %>2 = new <%= asEntity(entityClass) %>();
+        <%= asEntity(entityInstance) %>2.setId(<%= asEntity(entityInstance) %>1.getId());
+        assertThat(<%= asEntity(entityInstance) %>1).isEqualTo(<%= asEntity(entityInstance) %>2);
+        <%= asEntity(entityInstance) %>2.setId(<% if (databaseType === 'sql') { %>2L<% } else if (databaseType === 'mongodb' || databaseType === 'couchbase') { %>"id2"<% } else if (databaseType === 'cassandra') { %>UUID.randomUUID()<% } %>);
+        assertThat(<%= asEntity(entityInstance) %>1).isNotEqualTo(<%= asEntity(entityInstance) %>2);
+        <%= asEntity(entityInstance) %>1.setId(null);
+        assertThat(<%= asEntity(entityInstance) %>1).isNotEqualTo(<%= asEntity(entityInstance) %>2);
     }
     <%_ if (dto === 'mapstruct') { _%>
 
     @Test<% if (databaseType === 'sql') { %>
     @Transactional<% } %>
     public void dtoEqualsVerifier() throws Exception {
-        TestUtil.equalsVerifier(<%= entityClass %>DTO.class);
-        <%= entityClass %>DTO <%= entityInstance %>DTO1 = new <%= entityClass %>DTO();
-        <%= entityInstance %>DTO1.setId(<% if (databaseType === 'sql') { %>1L<% } else if (databaseType === 'mongodb' || databaseType === 'couchbase') { %>"id1"<% } else if (databaseType === 'cassandra') { %>UUID.randomUUID()<% } %>);
-        <%= entityClass %>DTO <%= entityInstance %>DTO2 = new <%= entityClass %>DTO();
-        assertThat(<%= entityInstance %>DTO1).isNotEqualTo(<%= entityInstance %>DTO2);
-        <%= entityInstance %>DTO2.setId(<%= entityInstance %>DTO1.getId());
-        assertThat(<%= entityInstance %>DTO1).isEqualTo(<%= entityInstance %>DTO2);
-        <%= entityInstance %>DTO2.setId(<% if (databaseType === 'sql') { %>2L<% } else if (databaseType === 'mongodb' || databaseType === 'couchbase') { %>"id2"<% } else if (databaseType === 'cassandra') { %>UUID.randomUUID()<% } %>);
-        assertThat(<%= entityInstance %>DTO1).isNotEqualTo(<%= entityInstance %>DTO2);
-        <%= entityInstance %>DTO1.setId(null);
-        assertThat(<%= entityInstance %>DTO1).isNotEqualTo(<%= entityInstance %>DTO2);
+        TestUtil.equalsVerifier(<%= asDto(entityClass) %>.class);
+        <%= asDto(entityClass) %> <%= asDto(entityInstance) %>1 = new <%= asDto(entityClass) %>();
+        <%= asDto(entityInstance) %>1.setId(<% if (databaseType === 'sql') { %>1L<% } else if (databaseType === 'mongodb' || databaseType === 'couchbase') { %>"id1"<% } else if (databaseType === 'cassandra') { %>UUID.randomUUID()<% } %>);
+        <%= asDto(entityClass) %> <%= asDto(entityInstance) %>2 = new <%= asDto(entityClass) %>();
+        assertThat(<%= asDto(entityInstance) %>1).isNotEqualTo(<%= asDto(entityInstance) %>2);
+        <%= asDto(entityInstance) %>2.setId(<%= asDto(entityInstance) %>1.getId());
+        assertThat(<%= asDto(entityInstance) %>1).isEqualTo(<%= asDto(entityInstance) %>2);
+        <%= asDto(entityInstance) %>2.setId(<% if (databaseType === 'sql') { %>2L<% } else if (databaseType === 'mongodb' || databaseType === 'couchbase') { %>"id2"<% } else if (databaseType === 'cassandra') { %>UUID.randomUUID()<% } %>);
+        assertThat(<%= asDto(entityInstance) %>1).isNotEqualTo(<%= asDto(entityInstance) %>2);
+        <%= asDto(entityInstance) %>1.setId(null);
+        assertThat(<%= asDto(entityInstance) %>1).isNotEqualTo(<%= asDto(entityInstance) %>2);
     }
         <%_ if (databaseType === 'sql') { _%>
 
diff --git a/generators/server/templates/src/test/java/package/security/DomainUserDetailsServiceIntTest.java.ejs b/generators/server/templates/src/test/java/package/security/DomainUserDetailsServiceIntTest.java.ejs
index 4f1a43df0c..2331050363 100644
--- a/generators/server/templates/src/test/java/package/security/DomainUserDetailsServiceIntTest.java.ejs
+++ b/generators/server/templates/src/test/java/package/security/DomainUserDetailsServiceIntTest.java.ejs
@@ -22,7 +22,7 @@ package <%= packageName %>.security;
 import <%= packageName %>.AbstractCassandraTest;
 <%_ } _%>
 import <%= packageName %>.<%= mainClass %>;
-import <%= packageName %>.domain.User;
+import <%= packageName %>.domain.<%= asEntity('User') %>;
 import <%= packageName %>.repository.<% if (reactive) { %>reactive.<% } %>UserRepository;
 
 import org.apache.commons.lang3.RandomStringUtils;
@@ -84,9 +84,9 @@ public class DomainUserDetailsServiceIntTest <% if (databaseType === 'cassandra'
     @Autowired
     private <% if (reactive) { %>Reactive<% } %>UserDetailsService domainUserDetailsService;
 
-    private User userOne;
-    private User userTwo;
-    private User userThree;
+    private <%= asEntity('User') %> userOne;
+    private <%= asEntity('User') %> userTwo;
+    private <%= asEntity('User') %> userThree;
 
     @Before
     public void init() {
@@ -94,7 +94,7 @@ public class DomainUserDetailsServiceIntTest <% if (databaseType === 'cassandra'
         userRepository.deleteAll()<% if (reactive) { %>.block()<% } %>;
 
         <%_ } _%>
-        userOne = new User();
+        userOne = new <%= asEntity('User') %>();
         <%_ if (databaseType === 'cassandra') { _%>
         userOne.setId(UUID.randomUUID().toString());
         <%_ } _%>
@@ -107,7 +107,7 @@ public class DomainUserDetailsServiceIntTest <% if (databaseType === 'cassandra'
         userOne.setLangKey("en");
         userRepository.save(userOne)<% if (reactive) { %>.block()<% } %>;
 
-        userTwo = new User();
+        userTwo = new <%= asEntity('User') %>();
         <%_ if (databaseType === 'cassandra') { _%>
         userTwo.setId(UUID.randomUUID().toString());
         <%_ } _%>
@@ -120,7 +120,7 @@ public class DomainUserDetailsServiceIntTest <% if (databaseType === 'cassandra'
         userTwo.setLangKey("en");
         userRepository.save(userTwo)<% if (reactive) { %>.block()<% } %>;
 
-        userThree = new User();
+        userThree = new <%= asEntity('User') %>();
         <%_ if (databaseType === 'cassandra') { _%>
         userThree.setId(UUID.randomUUID().toString());
         <%_ } _%>
diff --git a/generators/server/templates/src/test/java/package/service/MailServiceIntTest.java.ejs b/generators/server/templates/src/test/java/package/service/MailServiceIntTest.java.ejs
index 24cb14a5dc..ffd0b3a79a 100644
--- a/generators/server/templates/src/test/java/package/service/MailServiceIntTest.java.ejs
+++ b/generators/server/templates/src/test/java/package/service/MailServiceIntTest.java.ejs
@@ -21,7 +21,7 @@ import <%=packageName%>.config.Constants;
 <% if (databaseType === 'cassandra') { %>
 import <%=packageName%>.AbstractCassandraTest;<% } %>
 import <%=packageName%>.<%= mainClass %>;
-import <%=packageName%>.domain.User;
+import <%=packageName%>.domain.<%= asEntity('User') %>;
 import io.github.jhipster.config.JHipsterProperties;
 import org.junit.Before;
 import org.junit.Test;
@@ -138,7 +138,7 @@ public class MailServiceIntTest <% if (databaseType === 'cassandra') { %>extends
 
     @Test
     public void testSendEmailFromTemplate() throws Exception {
-        User user = new User();
+        <%= asEntity('User') %> user = new <%= asEntity('User') %>();
         user.setLogin("john");
         user.setEmail("john.doe@example.com");
         user.setLangKey("en");
@@ -155,7 +155,7 @@ public class MailServiceIntTest <% if (databaseType === 'cassandra') { %>extends
 
     @Test
     public void testSendActivationEmail() throws Exception {
-        User user = new User();
+        <%= asEntity('User') %> user = new <%= asEntity('User') %>();
         user.setLangKey(Constants.DEFAULT_LANGUAGE);
         user.setLogin("john");
         user.setEmail("john.doe@example.com");
@@ -170,7 +170,7 @@ public class MailServiceIntTest <% if (databaseType === 'cassandra') { %>extends
 
     @Test
     public void testCreationEmail() throws Exception {
-        User user = new User();
+        <%= asEntity('User') %> user = new <%= asEntity('User') %>();
         user.setLangKey(Constants.DEFAULT_LANGUAGE);
         user.setLogin("john");
         user.setEmail("john.doe@example.com");
@@ -185,7 +185,7 @@ public class MailServiceIntTest <% if (databaseType === 'cassandra') { %>extends
 
     @Test
     public void testSendPasswordResetMail() throws Exception {
-        User user = new User();
+        <%= asEntity('User') %> user = new <%= asEntity('User') %>();
         user.setLangKey(Constants.DEFAULT_LANGUAGE);
         user.setLogin("john");
         user.setEmail("john.doe@example.com");
diff --git a/generators/server/templates/src/test/java/package/service/UserServiceIntTest.java.ejs b/generators/server/templates/src/test/java/package/service/UserServiceIntTest.java.ejs
index d1da5b28ec..5b9830f32d 100644
--- a/generators/server/templates/src/test/java/package/service/UserServiceIntTest.java.ejs
+++ b/generators/server/templates/src/test/java/package/service/UserServiceIntTest.java.ejs
@@ -26,7 +26,7 @@ import <%= packageName %>.config.Constants;
 <%_ if ((databaseType === 'sql' || databaseType === 'mongodb' || databaseType === 'couchbase') && authenticationType === 'session') { _%>
 import <%= packageName %>.domain.PersistentToken;
 <%_ } _%>
-import <%= packageName %>.domain.User;
+import <%= packageName %>.domain.<%= asEntity('User') %>;
 <%_ if ((databaseType === 'sql' || databaseType === 'mongodb' || databaseType === 'couchbase') && authenticationType === 'session') { _%>
 import <%= packageName %>.repository.PersistentTokenRepository;
 <%_ } _%>
@@ -34,7 +34,7 @@ import <%= packageName %>.repository.PersistentTokenRepository;
 import <%= packageName %>.repository.search.UserSearchRepository;
 <%_ } _%>
 import <%= packageName %>.repository<% if (reactive) { %>.reactive<% } %>.UserRepository;
-import <%= packageName %>.service.dto.UserDTO;
+import <%= packageName %>.service.dto.<%= asDto('User') %>;
 <%_ if (authenticationType === 'oauth2') { _%>
 import <%= packageName %>.security.AuthoritiesConstants;
 <%_ } _%>
@@ -157,7 +157,7 @@ public class UserServiceIntTest <% if (databaseType === 'cassandra') { %>extends
     DateTimeProvider dateTimeProvider;
     <%_ } _%>
 
-    private User user;
+    private <%= asEntity('User') %> user;
 
     @Before
     public void init() {
@@ -170,7 +170,7 @@ public class UserServiceIntTest <% if (databaseType === 'cassandra') { %>extends
         <%_ if (databaseType !== 'sql') { _%>
         userRepository.deleteAll()<% if (reactive) { %>.block()<% } %>;
         <%_ } _%>
-        user = new User();
+        user = new <%= asEntity('User') %>();
         <%_ if (databaseType === 'cassandra') { _%>
         user.setId(UUID.randomUUID().toString());
         <%_ } _%>
@@ -217,7 +217,7 @@ public class UserServiceIntTest <% if (databaseType === 'cassandra') { %>extends
     <%_ } _%>
     public void assertThatUserMustExistToResetPassword() {
         userRepository.save<% if (databaseType === 'sql') { %>AndFlush<% } %>(user)<% if (reactive) { %>.block()<% } %>;
-        Optional<User> maybeUser = userService.requestPasswordReset("invalid.login@localhost")<% if (reactive) { %>.blockOptional()<% } %>;
+        Optional<<%= asEntity('User') %>> maybeUser = userService.requestPasswordReset("invalid.login@localhost")<% if (reactive) { %>.blockOptional()<% } %>;
         assertThat(maybeUser).isNotPresent();
 
         maybeUser = userService.requestPasswordReset(user.getEmail())<% if (reactive) { %>.blockOptional()<% } %>;
@@ -235,7 +235,7 @@ public class UserServiceIntTest <% if (databaseType === 'cassandra') { %>extends
         user.setActivated(false);
         userRepository.save<% if (databaseType === 'sql') { %>AndFlush<% } %>(user)<% if (reactive) { %>.block()<% } %>;
 
-        Optional<User> maybeUser = userService.requestPasswordReset(user.getLogin())<% if (reactive) { %>.blockOptional()<% } %>;
+        Optional<<%= asEntity('User') %>> maybeUser = userService.requestPasswordReset(user.getLogin())<% if (reactive) { %>.blockOptional()<% } %>;
         assertThat(maybeUser).isNotPresent();
         userRepository.delete(user)<% if (reactive) { %>.block()<% } %>;
     }
@@ -252,7 +252,7 @@ public class UserServiceIntTest <% if (databaseType === 'cassandra') { %>extends
         user.setResetKey(resetKey);
         userRepository.save<% if (databaseType === 'sql') { %>AndFlush<% } %>(user)<% if (reactive) { %>.block()<% } %>;
 
-        Optional<User> maybeUser = userService.completePasswordReset("johndoe2", user.getResetKey())<% if (reactive) { %>.blockOptional()<% } %>;
+        Optional<<%= asEntity('User') %>> maybeUser = userService.completePasswordReset("johndoe2", user.getResetKey())<% if (reactive) { %>.blockOptional()<% } %>;
         assertThat(maybeUser).isNotPresent();
         userRepository.delete(user)<% if (reactive) { %>.block()<% } %>;
     }
@@ -268,7 +268,7 @@ public class UserServiceIntTest <% if (databaseType === 'cassandra') { %>extends
         user.setResetKey("1234");
         userRepository.save<% if (databaseType === 'sql') { %>AndFlush<% } %>(user)<% if (reactive) { %>.block()<% } %>;
 
-        Optional<User> maybeUser = userService.completePasswordReset("johndoe2", user.getResetKey())<% if (reactive) { %>.blockOptional()<% } %>;
+        Optional<<%= asEntity('User') %>> maybeUser = userService.completePasswordReset("johndoe2", user.getResetKey())<% if (reactive) { %>.blockOptional()<% } %>;
         assertThat(maybeUser).isNotPresent();
         userRepository.delete(user)<% if (reactive) { %>.block()<% } %>;
     }
@@ -286,7 +286,7 @@ public class UserServiceIntTest <% if (databaseType === 'cassandra') { %>extends
         user.setResetKey(resetKey);
         userRepository.save<% if (databaseType === 'sql') { %>AndFlush<% } %>(user)<% if (reactive) { %>.block()<% } %>;
 
-        Optional<User> maybeUser = userService.completePasswordReset("johndoe2", user.getResetKey())<% if (reactive) { %>.blockOptional()<% } %>;
+        Optional<<%= asEntity('User') %>> maybeUser = userService.completePasswordReset("johndoe2", user.getResetKey())<% if (reactive) { %>.blockOptional()<% } %>;
         assertThat(maybeUser).isPresent();
         assertThat(maybeUser.orElse(null).getResetDate()).isNull();
         assertThat(maybeUser.orElse(null).getResetKey()).isNull();
@@ -305,10 +305,10 @@ public class UserServiceIntTest <% if (databaseType === 'cassandra') { %>extends
         when(dateTimeProvider.getNow()).thenReturn(Optional.of(now.minus(4, ChronoUnit.DAYS)));
         <%_ } _%>
         user.setActivated(false);
-        User dbUser = userRepository.save<% if (databaseType === 'sql') { %>AndFlush<% } %>(user)<% if (reactive) { %>.block()<% } %>;
+        <%= asEntity('User') %> dbUser = userRepository.save<% if (databaseType === 'sql') { %>AndFlush<% } %>(user)<% if (reactive) { %>.block()<% } %>;
         dbUser.setCreatedDate(now.minus(4, ChronoUnit.DAYS));
         userRepository.save<% if (databaseType === 'sql') { %>AndFlush<% } %>(user)<% if (reactive) { %>.block()<% } %>;
-        List<User> users = userRepository.findAllByActivatedIsFalseAndCreatedDateBefore(now.minus(3, ChronoUnit.DAYS))<% if (reactive) { %>
+        List<<%= asEntity('User') %>> users = userRepository.findAllByActivatedIsFalseAndCreatedDateBefore(now.minus(3, ChronoUnit.DAYS))<% if (reactive) { %>
             .collectList().block()<% } %>;
         assertThat(users).isNotEmpty();
         userService.removeNotActivatedUsers();
@@ -324,7 +324,7 @@ public class UserServiceIntTest <% if (databaseType === 'cassandra') { %>extends
     <%_ } _%>
     <%_ if ((databaseType === 'sql' || databaseType === 'mongodb' || databaseType === 'couchbase') && authenticationType === 'session') { _%>
 
-    private void generateUserToken(User user, String tokenSeries, LocalDate localDate) {
+    private void generateUserToken(<%= asEntity('User') %> user, String tokenSeries, LocalDate localDate) {
         PersistentToken token = new PersistentToken();
         token.setSeries(tokenSeries);<% if (databaseType === 'couchbase') { %>
         token.setLogin(user.getLogin());<% } else { %>
@@ -352,10 +352,10 @@ public class UserServiceIntTest <% if (databaseType === 'cassandra') { %>extends
             userRepository.save<% if (databaseType === 'sql') { %>AndFlush<% } %>(user)<% if (reactive) { %>.block()<% } %>;
         }<% if (databaseType === 'sql' || databaseType === 'mongodb' || databaseType === 'couchbase') { %>
         final PageRequest pageable = PageRequest.of(0, (int) userRepository.count()<% if (reactive) { %>.block().intValue()<% } %>);
-        final <% if (reactive) { %>List<% } else { %>Page<% } %><UserDTO> allManagedUsers = userService.getAllManagedUsers(pageable)<% if (reactive) { %>
+        final <% if (reactive) { %>List<% } else { %>Page<% } %><<%= asDto('User') %>> allManagedUsers = userService.getAllManagedUsers(pageable)<% if (reactive) { %>
             .collectList().block()<% } %>;
         assertThat(allManagedUsers<% if (!reactive) { %>.getContent()<% } %>.stream()<% } %><% if (databaseType === 'cassandra') { %>
-        final List<UserDTO> allManagedUsers = userService.getAllManagedUsers();
+        final List<<%= asDto('User') %>> allManagedUsers = userService.getAllManagedUsers();
         assertThat(allManagedUsers.stream()<% } %>
             .noneMatch(user -> Constants.ANONYMOUS_USER.equals(user.getLogin())))
             .isTrue();
@@ -412,7 +412,7 @@ public class UserServiceIntTest <% if (databaseType === 'cassandra') { %>extends
 
         OAuth2Authentication authentication = createMockOAuth2AuthenticationWithDetails(userDetails);
 
-        UserDTO userDTO = userService.getUserFromAuthentication(authentication);
+        <%= asDto('User') %> userDTO = userService.getUserFromAuthentication(authentication);
 
         assertThat(userDTO.getLangKey()).isEqualTo("en");
 
diff --git a/generators/server/templates/src/test/java/package/service/mapper/UserMapperTest.java.ejs b/generators/server/templates/src/test/java/package/service/mapper/UserMapperTest.java.ejs
index f90cd5cbd1..a4f3176f67 100644
--- a/generators/server/templates/src/test/java/package/service/mapper/UserMapperTest.java.ejs
+++ b/generators/server/templates/src/test/java/package/service/mapper/UserMapperTest.java.ejs
@@ -3,8 +3,8 @@ package <%= packageName %>.service.mapper;
 <% if (databaseType === 'cassandra') { %>
 import <%=packageName%>.AbstractCassandraTest;<% } %>
 import <%= packageName %>.<%= mainClass %>;
-import <%= packageName %>.domain.User;
-import <%= packageName %>.service.dto.UserDTO;
+import <%= packageName %>.domain.<%= asEntity('User') %>;
+import <%= packageName %>.service.dto.<%= asDto('User') %>;
 <%_ if (authenticationType !== 'oauth2') { _%>
 import org.apache.commons.lang3.RandomStringUtils;
 <%_ } _%>
@@ -36,20 +36,20 @@ public class UserMapperTest <% if (databaseType === 'cassandra') { %>extends Abs
     @Autowired
     private UserMapper userMapper;
 
-    private User user;
-    private UserDTO userDto;
+    private <%= asEntity('User') %> user;
+    private <%= asDto('User') %> userDto;
 
     <%_ if (databaseType === 'sql' && authenticationType !== 'oauth2') { _%>
     private static final Long DEFAULT_ID = 1L;
     <%_ } else if (databaseType === 'couchbase'){ _%>
-    private static final String DEFAULT_ID = User.PREFIX + DEFAULT_LOGIN;
+    private static final String DEFAULT_ID = <%= asEntity('User') %>.PREFIX + DEFAULT_LOGIN;
     <%_ } else { _%>
     private static final String DEFAULT_ID = "id1";
     <%_ } _%>
 
     @Before
     public void init() {
-        user = new User();
+        user = new <%= asEntity('User') %>();
         user.setLogin(DEFAULT_LOGIN);
         <%_ if (authenticationType !== 'oauth2') { _%>
         user.setPassword(RandomStringUtils.random(60));
@@ -63,16 +63,16 @@ public class UserMapperTest <% if (databaseType === 'cassandra') { %>extends Abs
         <%_ } _%>
         user.setLangKey("en");
 
-        userDto = new UserDTO(user);
+        userDto = new <%= asDto('User') %>(user);
     }
 
     @Test
     public void usersToUserDTOsShouldMapOnlyNonNullUsers(){
-        List<User> users = new ArrayList<>();
+        List<<%= asEntity('User') %>> users = new ArrayList<>();
         users.add(user);
         users.add(null);
 
-        List<UserDTO> userDTOS = userMapper.usersToUserDTOs(users);
+        List<<%= asDto('User') %>> userDTOS = userMapper.usersToUserDTOs(users);
 
         assertThat(userDTOS).isNotEmpty();
         assertThat(userDTOS).size().isEqualTo(1);
@@ -80,11 +80,11 @@ public class UserMapperTest <% if (databaseType === 'cassandra') { %>extends Abs
 
     @Test
     public void userDTOsToUsersShouldMapOnlyNonNullUsers(){
-        List<UserDTO> usersDto = new ArrayList<>();
+        List<<%= asDto('User') %>> usersDto = new ArrayList<>();
         usersDto.add(userDto);
         usersDto.add(null);
 
-        List<User> users = userMapper.userDTOsToUsers(usersDto);
+        List<<%= asEntity('User') %>> users = userMapper.userDTOsToUsers(usersDto);
 
         assertThat(users).isNotEmpty();
         assertThat(users).size().isEqualTo(1);
@@ -96,10 +96,10 @@ public class UserMapperTest <% if (databaseType === 'cassandra') { %>extends Abs
         authoritiesAsString.add("ADMIN");
         userDto.setAuthorities(authoritiesAsString);
 
-        List<UserDTO> usersDto = new ArrayList<>();
+        List<<%= asDto('User') %>> usersDto = new ArrayList<>();
         usersDto.add(userDto);
 
-        List<User> users = userMapper.userDTOsToUsers(usersDto);
+        List<<%= asEntity('User') %>> users = userMapper.userDTOsToUsers(usersDto);
 
         assertThat(users).isNotEmpty();
         assertThat(users).size().isEqualTo(1);
@@ -117,10 +117,10 @@ public class UserMapperTest <% if (databaseType === 'cassandra') { %>extends Abs
     public void userDTOsToUsersMapWithNullAuthoritiesStringShouldReturnUserWithEmptyAuthorities(){
         userDto.setAuthorities(null);
 
-        List<UserDTO> usersDto = new ArrayList<>();
+        List<<%= asDto('User') %>> usersDto = new ArrayList<>();
         usersDto.add(userDto);
 
-        List<User> users = userMapper.userDTOsToUsers(usersDto);
+        List<<%= asEntity('User') %>> users = userMapper.userDTOsToUsers(usersDto);
 
         assertThat(users).isNotEmpty();
         assertThat(users).size().isEqualTo(1);
@@ -136,7 +136,7 @@ public class UserMapperTest <% if (databaseType === 'cassandra') { %>extends Abs
 
         userDto.setAuthorities(authoritiesAsString);
 
-        User user = userMapper.userDTOToUser(userDto);
+        <%= asEntity('User') %> user = userMapper.userDTOToUser(userDto);
 
         assertThat(user).isNotNull();
         assertThat(user.getAuthorities()).isNotNull();
@@ -153,7 +153,7 @@ public class UserMapperTest <% if (databaseType === 'cassandra') { %>extends Abs
     public void userDTOToUserMapWithNullAuthoritiesStringShouldReturnUserWithEmptyAuthorities(){
         userDto.setAuthorities(null);
 
-        User user = userMapper.userDTOToUser(userDto);
+        <%= asEntity('User') %> user = userMapper.userDTOToUser(userDto);
 
         assertThat(user).isNotNull();
         assertThat(user.getAuthorities()).isNotNull();
diff --git a/generators/server/templates/src/test/java/package/web/rest/AccountResourceIntTest.java.ejs b/generators/server/templates/src/test/java/package/web/rest/AccountResourceIntTest.java.ejs
index 251838036b..190dfcec91 100644
--- a/generators/server/templates/src/test/java/package/web/rest/AccountResourceIntTest.java.ejs
+++ b/generators/server/templates/src/test/java/package/web/rest/AccountResourceIntTest.java.ejs
@@ -24,7 +24,7 @@ import <%=packageName%>.AbstractCassandraTest;
 <%_ } _%>
 import <%=packageName%>.<%= mainClass %>;
 import <%=packageName%>.domain.Authority;
-import <%=packageName%>.domain.User;
+import <%=packageName%>.domain.<%= asEntity('User') %>;
 import <%=packageName%>.repository.UserRepository;
 import <%=packageName%>.security.AuthoritiesConstants;
 import <%=packageName%>.service.UserService;
@@ -120,7 +120,7 @@ public class AccountResourceIntTest<% if (databaseType === 'cassandra') { %>exte
         authorities.add(AuthoritiesConstants.ADMIN);
         <%_ } _%>
 
-        User user = new User();
+        <%= asEntity('User') %> user = new <%= asEntity('User') %>();
         <%_ if (authenticationType === 'oauth2' && databaseType !== 'couchbase') { _%>
         user.setId(RandomStringUtils.randomAlphanumeric(50));
         <%_ } _%>
@@ -173,7 +173,7 @@ import <%=packageName%>.domain.Authority;
 <%_ if (authenticationType === 'session') { _%>
 import <%=packageName%>.domain.PersistentToken;
 <%_ } _%>
-import <%=packageName%>.domain.User;
+import <%=packageName%>.domain.<%= asEntity('User') %>;
 <%_ if (databaseType === 'sql' || databaseType === 'mongodb' || databaseType === 'couchbase') { _%>
 import <%=packageName%>.repository<% if (reactive) { %>.reactive<% } %>.AuthorityRepository;
 <%_ } _%>
@@ -185,7 +185,7 @@ import <%=packageName%>.security.AuthoritiesConstants;
 import <%=packageName%>.service.MailService;
 import <%=packageName%>.service.UserService;
 import <%=packageName%>.service.dto.PasswordChangeDTO;
-import <%=packageName%>.service.dto.UserDTO;
+import <%=packageName%>.service.dto.<%= asDto('User') %>;
 import <%=packageName%>.web.rest.errors.ExceptionTranslator;
 import <%=packageName%>.web.rest.vm.KeyAndPasswordVM;
 import <%=packageName%>.web.rest.vm.ManagedUserVM;
@@ -374,7 +374,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
         Set<String> authorities = new HashSet<>();
         authorities.add(AuthoritiesConstants.ADMIN);<% } %>
 
-        User user = new User();
+        <%= asEntity('User') %> user = new <%= asEntity('User') %>();
         user.setLogin("test");
         user.setFirstName("john");
         user.setLastName("doe");
@@ -499,7 +499,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
             .expectStatus().isBadRequest();
         <%_ } _%>
 
-        Optional<User> user = userRepository.findOneByEmailIgnoreCase("funky@example.com")<% if (reactive) { %>.blockOptional()<% } %>;
+        Optional<<%= asEntity('User') %>> user = userRepository.findOneByEmailIgnoreCase("funky@example.com")<% if (reactive) { %>.blockOptional()<% } %>;
         assertThat(user.isPresent()).isFalse();
     }
 
@@ -533,7 +533,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
             .expectStatus().isBadRequest();
         <%_ } _%>
 
-        Optional<User> user = userRepository.findOneByLogin("bob")<% if (reactive) { %>.blockOptional()<% } %>;
+        Optional<<%= asEntity('User') %>> user = userRepository.findOneByLogin("bob")<% if (reactive) { %>.blockOptional()<% } %>;
         assertThat(user.isPresent()).isFalse();
     }
 
@@ -567,7 +567,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
             .expectStatus().isBadRequest();
         <%_ } _%>
 
-        Optional<User> user = userRepository.findOneByLogin("bob")<% if (reactive) { %>.blockOptional()<% } %>;
+        Optional<<%= asEntity('User') %>> user = userRepository.findOneByLogin("bob")<% if (reactive) { %>.blockOptional()<% } %>;
         assertThat(user.isPresent()).isFalse();
     }
 
@@ -601,7 +601,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
             .expectStatus().isBadRequest();
         <%_ } _%>
 
-        Optional<User> user = userRepository.findOneByLogin("bob")<% if (reactive) { %>.blockOptional()<% } %>;
+        Optional<<%= asEntity('User') %>> user = userRepository.findOneByLogin("bob")<% if (reactive) { %>.blockOptional()<% } %>;
         assertThat(user.isPresent()).isFalse();
     }
 
@@ -670,7 +670,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
             .expectStatus().isCreated();
         <%_ } _%>
 
-        Optional<User> testUser = userRepository.findOneByEmailIgnoreCase("alice2@example.com")<% if (reactive) { %>.blockOptional()<% } %>;
+        Optional<<%= asEntity('User') %>> testUser = userRepository.findOneByEmailIgnoreCase("alice2@example.com")<% if (reactive) { %>.blockOptional()<% } %>;
         assertThat(testUser.isPresent()).isTrue();
         testUser.get().setActivated(true);
         userRepository.save(testUser.get())<% if (reactive) { %>.block()<% } %>;
@@ -722,7 +722,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
             .expectStatus().isCreated();
         <%_ } _%>
 
-        Optional<User> testUser1 = userRepository.findOneByLogin("test-register-duplicate-email")<% if (reactive) { %>.blockOptional()<% } %>;
+        Optional<<%= asEntity('User') %>> testUser1 = userRepository.findOneByLogin("test-register-duplicate-email")<% if (reactive) { %>.blockOptional()<% } %>;
         assertThat(testUser1.isPresent()).isTrue();
 
         // Duplicate email, different login
@@ -753,10 +753,10 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
             .expectStatus().isCreated();
         <%_ } _%>
 
-        Optional<User> testUser2 = userRepository.findOneByLogin("test-register-duplicate-email")<% if (reactive) { %>.blockOptional()<% } %>;
+        Optional<<%= asEntity('User') %>> testUser2 = userRepository.findOneByLogin("test-register-duplicate-email")<% if (reactive) { %>.blockOptional()<% } %>;
         assertThat(testUser2.isPresent()).isFalse();
 
-        Optional<User> testUser3 = userRepository.findOneByLogin("test-register-duplicate-email-2")<% if (reactive) { %>.blockOptional()<% } %>;
+        Optional<<%= asEntity('User') %>> testUser3 = userRepository.findOneByLogin("test-register-duplicate-email-2")<% if (reactive) { %>.blockOptional()<% } %>;
         assertThat(testUser3.isPresent()).isTrue();
 
         // Duplicate email - with uppercase email address
@@ -788,12 +788,12 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
             .expectStatus().isCreated();
         <%_ } _%>
 
-        Optional<User> testUser4 = userRepository.findOneByLogin("test-register-duplicate-email-3")<% if (reactive) { %>.blockOptional()<% } %>;
+        Optional<<%= asEntity('User') %>> testUser4 = userRepository.findOneByLogin("test-register-duplicate-email-3")<% if (reactive) { %>.blockOptional()<% } %>;
         assertThat(testUser4.isPresent()).isTrue();
         assertThat(testUser4.get().getEmail()).isEqualTo("test-register-duplicate-email@example.com");
 
         testUser4.get().setActivated(true);
-        userService.updateUser((new UserDTO(testUser4.get())))<% if (reactive) { %>.block()<% } %>;
+        userService.updateUser((new <%= asDto('User') %>(testUser4.get())))<% if (reactive) { %>.block()<% } %>;
 
         // Register 4th (already activated) user
         <%_ if (!reactive) { _%>
@@ -841,7 +841,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
             .expectStatus().isCreated();
         <%_ } _%>
 
-        Optional<User> userDup = userRepository.findOneByLogin("badguy")<% if (reactive) { %>.blockOptional()<% } %>;
+        Optional<<%= asEntity('User') %>> userDup = userRepository.findOneByLogin("badguy")<% if (reactive) { %>.blockOptional()<% } %>;
         assertThat(userDup.isPresent()).isTrue();
         assertThat(userDup.get().getAuthorities()).hasSize(1)
             .containsExactly(<% if (databaseType === 'sql' || databaseType === 'mongodb') { %>authorityRepository.findById(AuthoritiesConstants.USER).<% if (reactive) { %>block<% } else { %>get<% } %>()<% } %><% if (databaseType === 'cassandra' || databaseType === 'couchbase') { %>AuthoritiesConstants.USER<% } %>);
@@ -851,7 +851,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
     @Transactional<% } %>
     public void testActivateAccount()<% if (!reactive) { %> throws Exception<% } %> {
         final String activationKey = "some activation key";
-        User user = new User();
+        <%= asEntity('User') %> user = new <%= asEntity('User') %>();
         <%_ if (databaseType === 'cassandra') { _%>
         user.setId(UUID.randomUUID().toString());
         <%_ } _%>
@@ -894,7 +894,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
     @Transactional<% } %>
     @WithMockUser("save-account")
     public void testSaveAccount() throws Exception {
-        User user = new User();
+        <%= asEntity('User') %> user = new <%= asEntity('User') %>();
         <%_ if (databaseType === 'cassandra') { _%>
         user.setId(UUID.randomUUID().toString());
         <%_ } _%>
@@ -905,7 +905,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
 
         userRepository.save<% if (databaseType === 'sql') { %>AndFlush<% } %>(user)<% if (reactive) { %>.block()<% } %>;
 
-        UserDTO userDTO = new UserDTO();
+        <%= asDto('User') %> userDTO = new <%= asDto('User') %>();
         userDTO.setLogin("not-used");
         userDTO.setFirstName("firstname");
         userDTO.setLastName("lastname");
@@ -931,7 +931,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
             .expectStatus().isOk();
         <%_ } _%>
 
-        User updatedUser = userRepository.findOneByLogin(user.getLogin())<% if (!reactive) { %>.orElse(null)<% } else { %>.block()<% } %>;
+        <%= asEntity('User') %> updatedUser = userRepository.findOneByLogin(user.getLogin())<% if (!reactive) { %>.orElse(null)<% } else { %>.block()<% } %>;
         assertThat(updatedUser.getFirstName()).isEqualTo(userDTO.getFirstName());
         assertThat(updatedUser.getLastName()).isEqualTo(userDTO.getLastName());
         assertThat(updatedUser.getEmail()).isEqualTo(userDTO.getEmail());
@@ -946,7 +946,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
     @Transactional<% } %>
     @WithMockUser("save-invalid-email")
     public void testSaveInvalidEmail() throws Exception {
-        User user = new User();
+        <%= asEntity('User') %> user = new <%= asEntity('User') %>();
         <%_ if (databaseType === 'cassandra') { _%>
         user.setId(UUID.randomUUID().toString());
         <%_ } _%>
@@ -957,7 +957,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
 
         userRepository.save<% if (databaseType === 'sql') { %>AndFlush<% } %>(user)<% if (reactive) { %>.block()<% } %>;
 
-        UserDTO userDTO = new UserDTO();
+        <%= asDto('User') %> userDTO = new <%= asDto('User') %>();
         userDTO.setLogin("not-used");
         userDTO.setFirstName("firstname");
         userDTO.setLastName("lastname");
@@ -990,7 +990,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
     @Transactional<% } %>
     @WithMockUser("save-existing-email")
     public void testSaveExistingEmail() throws Exception {
-        User user = new User();
+        <%= asEntity('User') %> user = new <%= asEntity('User') %>();
         <%_ if (databaseType === 'cassandra') { _%>
         user.setId(UUID.randomUUID().toString());
         <%_ } _%>
@@ -1001,7 +1001,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
 
         userRepository.save<% if (databaseType === 'sql') { %>AndFlush<% } %>(user)<% if (reactive) { %>.block()<% } %>;
 
-        User anotherUser = new User();
+        <%= asEntity('User') %> anotherUser = new <%= asEntity('User') %>();
         <%_ if (databaseType === 'cassandra') { _%>
         anotherUser.setId(UUID.randomUUID().toString());
         <%_ } _%>
@@ -1012,7 +1012,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
 
         userRepository.save<% if (databaseType === 'sql') { %>AndFlush<% } %>(anotherUser)<% if (reactive) { %>.block()<% } %>;
 
-        UserDTO userDTO = new UserDTO();
+        <%= asDto('User') %> userDTO = new <%= asDto('User') %>();
         userDTO.setLogin("not-used");
         userDTO.setFirstName("firstname");
         userDTO.setLastName("lastname");
@@ -1038,7 +1038,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
             .expectStatus().isBadRequest();
         <%_ } _%>
 
-        User updatedUser = userRepository.findOneByLogin("save-existing-email")<% if (!reactive) { %>.orElse(null)<% } else { %>.block()<% } %>;
+        <%= asEntity('User') %> updatedUser = userRepository.findOneByLogin("save-existing-email")<% if (!reactive) { %>.orElse(null)<% } else { %>.block()<% } %>;
         assertThat(updatedUser.getEmail()).isEqualTo("save-existing-email@example.com");
     }
 
@@ -1046,7 +1046,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
     @Transactional<% } %>
     @WithMockUser("save-existing-email-and-login")
     public void testSaveExistingEmailAndLogin() throws Exception {
-        User user = new User();
+        <%= asEntity('User') %> user = new <%= asEntity('User') %>();
         <%_ if (databaseType === 'cassandra') { _%>
         user.setId(UUID.randomUUID().toString());
         <%_ } _%>
@@ -1057,7 +1057,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
 
         userRepository.save<% if (databaseType === 'sql') { %>AndFlush<% } %>(user)<% if (reactive) { %>.block()<% } %>;
 
-        UserDTO userDTO = new UserDTO();
+        <%= asDto('User') %> userDTO = new <%= asDto('User') %>();
         userDTO.setLogin("not-used");
         userDTO.setFirstName("firstname");
         userDTO.setLastName("lastname");
@@ -1083,7 +1083,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
             .expectStatus().isOk();
         <%_ } _%>
 
-        User updatedUser = userRepository.findOneByLogin("save-existing-email-and-login")<% if (!reactive) { %>.orElse(null)<% } else { %>.block()<% } %>;
+        <%= asEntity('User') %> updatedUser = userRepository.findOneByLogin("save-existing-email-and-login")<% if (!reactive) { %>.orElse(null)<% } else { %>.block()<% } %>;
         assertThat(updatedUser.getEmail()).isEqualTo("save-existing-email-and-login@example.com");
     }
 
@@ -1091,7 +1091,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
     @Transactional<% } %>
     @WithMockUser("change-password-wrong-existing-password")
     public void testChangePasswordWrongExistingPassword() throws Exception {
-        User user = new User();
+        <%= asEntity('User') %> user = new <%= asEntity('User') %>();
     <%_ if (databaseType === 'cassandra') { _%>
         user.setId(UUID.randomUUID().toString());
     <%_ } _%>
@@ -1114,7 +1114,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
             .expectStatus().isBadRequest();
         <%_ } _%>
 
-        User updatedUser = userRepository.findOneByLogin("change-password-wrong-existing-password")<% if (!reactive) { %>.orElse(null)<% } else { %>.block()<% } %>;
+        <%= asEntity('User') %> updatedUser = userRepository.findOneByLogin("change-password-wrong-existing-password")<% if (!reactive) { %>.orElse(null)<% } else { %>.block()<% } %>;
         assertThat(passwordEncoder.matches("new password", updatedUser.getPassword())).isFalse();
         assertThat(passwordEncoder.matches(currentPassword, updatedUser.getPassword())).isTrue();
     }
@@ -1123,7 +1123,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
     @Transactional<% } %>
     @WithMockUser("change-password")
     public void testChangePassword() throws Exception {
-        User user = new User();
+        <%= asEntity('User') %> user = new <%= asEntity('User') %>();
         <%_ if (databaseType === 'cassandra') { _%>
         user.setId(UUID.randomUUID().toString());
         <%_ } _%>
@@ -1146,7 +1146,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
             .expectStatus().isOk();
         <%_ } _%>
 
-        User updatedUser = userRepository.findOneByLogin("change-password")<% if (!reactive) { %>.orElse(null)<% } else { %>.block()<% } %>;
+        <%= asEntity('User') %> updatedUser = userRepository.findOneByLogin("change-password")<% if (!reactive) { %>.orElse(null)<% } else { %>.block()<% } %>;
         assertThat(passwordEncoder.matches("new password", updatedUser.getPassword())).isTrue();
     }
 
@@ -1154,7 +1154,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
     @Transactional<% } %>
     @WithMockUser("change-password-too-small")
     public void testChangePasswordTooSmall() throws Exception {
-        User user = new User();
+        <%= asEntity('User') %> user = new <%= asEntity('User') %>();
         <%_ if (databaseType === 'cassandra') { _%>
         user.setId(UUID.randomUUID().toString());
         <%_ } _%>
@@ -1177,7 +1177,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
             .expectStatus().isBadRequest();
         <%_ } _%>
 
-        User updatedUser = userRepository.findOneByLogin("change-password-too-small")<% if (!reactive) { %>.orElse(null)<% } else { %>.block()<% } %>;
+        <%= asEntity('User') %> updatedUser = userRepository.findOneByLogin("change-password-too-small")<% if (!reactive) { %>.orElse(null)<% } else { %>.block()<% } %>;
         assertThat(updatedUser.getPassword()).isEqualTo(user.getPassword());
     }
 
@@ -1185,7 +1185,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
     @Transactional<% } %>
     @WithMockUser("change-password-too-long")
     public void testChangePasswordTooLong() throws Exception {
-        User user = new User();
+        <%= asEntity('User') %> user = new <%= asEntity('User') %>();
         <%_ if (databaseType === 'cassandra') { _%>
         user.setId(UUID.randomUUID().toString());
         <%_ } _%>
@@ -1208,7 +1208,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
             .expectStatus().isBadRequest();
         <%_ } _%>
 
-        User updatedUser = userRepository.findOneByLogin("change-password-too-long")<% if (!reactive) { %>.orElse(null)<% } else { %>.block()<% } %>;
+        <%= asEntity('User') %> updatedUser = userRepository.findOneByLogin("change-password-too-long")<% if (!reactive) { %>.orElse(null)<% } else { %>.block()<% } %>;
         assertThat(updatedUser.getPassword()).isEqualTo(user.getPassword());
     }
 
@@ -1216,7 +1216,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
     @Transactional<% } %>
     @WithMockUser("change-password-empty")
     public void testChangePasswordEmpty()<% if (!reactive) { %> throws Exception<% } %> {
-        User user = new User();
+        <%= asEntity('User') %> user = new <%= asEntity('User') %>();
         <%_ if (databaseType === 'cassandra') { _%>
         user.setId(UUID.randomUUID().toString());
         <%_ } _%>
@@ -1235,7 +1235,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
             .expectStatus().isBadRequest();
         <%_ } _%>
 
-        User updatedUser = userRepository.findOneByLogin("change-password-empty")<% if (!reactive) { %>.orElse(null)<% } else { %>.block()<% } %>;
+        <%= asEntity('User') %> updatedUser = userRepository.findOneByLogin("change-password-empty")<% if (!reactive) { %>.orElse(null)<% } else { %>.block()<% } %>;
         assertThat(updatedUser.getPassword()).isEqualTo(user.getPassword());
     }
     <%_ if (authenticationType === 'session') { _%>
@@ -1244,7 +1244,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
     @Transactional<% } %>
     @WithMockUser("current-sessions")
     public void testGetCurrentSessions() throws Exception {
-        User user = new User();
+        <%= asEntity('User') %> user = new <%= asEntity('User') %>();
         <%_ if (databaseType === 'cassandra') { _%>
         user.setId(UUID.randomUUID().toString());
         <%_ } _%>
@@ -1277,7 +1277,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
     @Transactional<% } %>
     @WithMockUser("invalidate-session")
     public void testInvalidateSession() throws Exception {
-        User user = new User();
+        <%= asEntity('User') %> user = new <%= asEntity('User') %>();
         <%_ if (databaseType === 'cassandra') { _%>
         user.setId(UUID.randomUUID().toString());
         <%_ } _%>
@@ -1310,7 +1310,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
     @Test<% if (databaseType === 'sql') { %>
     @Transactional<% } %>
     public void testRequestPasswordReset()<% if (!reactive) { %> throws Exception<% } %> {
-        User user = new User();
+        <%= asEntity('User') %> user = new <%= asEntity('User') %>();
         <%_ if (databaseType === 'cassandra') { _%>
         user.setId(UUID.randomUUID().toString());
         <%_ } _%>
@@ -1335,7 +1335,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
     @Test<% if (databaseType === 'sql') { %>
     @Transactional<% } %>
     public void testRequestPasswordResetUpperCaseEmail()<% if (!reactive) { %> throws Exception<% } %> {
-        User user = new User();
+        <%= asEntity('User') %> user = new <%= asEntity('User') %>();
         <%_ if (databaseType === 'cassandra') { _%>
         user.setId(UUID.randomUUID().toString());
         <%_ } _%>
@@ -1376,7 +1376,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
     @Test<% if (databaseType === 'sql') { %>
     @Transactional<% } %>
     public void testFinishPasswordReset() throws Exception {
-        User user = new User();
+        <%= asEntity('User') %> user = new <%= asEntity('User') %>();
         <%_ if (databaseType === 'cassandra') { _%>
         user.setId(UUID.randomUUID().toString());
         <%_ } _%>
@@ -1405,14 +1405,14 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
             .expectStatus().isOk();
         <%_ } _%>
 
-        User updatedUser = userRepository.findOneByLogin(user.getLogin())<% if (!reactive) { %>.orElse(null)<% } else { %>.block()<% } %>;
+        <%= asEntity('User') %> updatedUser = userRepository.findOneByLogin(user.getLogin())<% if (!reactive) { %>.orElse(null)<% } else { %>.block()<% } %>;
         assertThat(passwordEncoder.matches(keyAndPassword.getNewPassword(), updatedUser.getPassword())).isTrue();
     }
 
     @Test<% if (databaseType === 'sql') { %>
     @Transactional<% } %>
     public void testFinishPasswordResetTooSmall() throws Exception {
-        User user = new User();
+        <%= asEntity('User') %> user = new <%= asEntity('User') %>();
         <%_ if (databaseType === 'cassandra') { _%>
         user.setId(UUID.randomUUID().toString());
         <%_ } _%>
@@ -1441,7 +1441,7 @@ public class AccountResourceIntTest <% if (databaseType === 'cassandra') { %>ext
             .expectStatus().isBadRequest();
         <%_ } _%>
 
-        User updatedUser = userRepository.findOneByLogin(user.getLogin())<% if (!reactive) { %>.orElse(null)<% } else { %>.block()<% } %>;
+        <%= asEntity('User') %> updatedUser = userRepository.findOneByLogin(user.getLogin())<% if (!reactive) { %>.orElse(null)<% } else { %>.block()<% } %>;
         assertThat(passwordEncoder.matches(keyAndPassword.getNewPassword(), updatedUser.getPassword())).isFalse();
     }
 
diff --git a/generators/server/templates/src/test/java/package/web/rest/UserJWTControllerIntTest.java.ejs b/generators/server/templates/src/test/java/package/web/rest/UserJWTControllerIntTest.java.ejs
index 2862888130..be5f90d460 100644
--- a/generators/server/templates/src/test/java/package/web/rest/UserJWTControllerIntTest.java.ejs
+++ b/generators/server/templates/src/test/java/package/web/rest/UserJWTControllerIntTest.java.ejs
@@ -22,7 +22,7 @@ package <%=packageName%>.web.rest;
 import <%=packageName%>.AbstractCassandraTest;
 <%_ } _%>
 import <%=packageName%>.<%= mainClass %>;
-import <%=packageName%>.domain.User;
+import <%=packageName%>.domain.<%= asEntity('User') %>;
 import <%=packageName%>.repository<% if (reactive) { %>.reactive<% } %>.UserRepository;
 import <%=packageName%>.security.jwt.TokenProvider;
 import <%=packageName%>.web.rest.errors.ExceptionTranslator;
@@ -106,7 +106,7 @@ public class UserJWTControllerIntTest <% if (databaseType === 'cassandra') { %>e
     @Transactional
     <%_ } _%>
     public void testAuthorize() throws Exception {
-        User user = new User();
+        <%= asEntity('User') %> user = new <%= asEntity('User') %>();
         <%_ if (databaseType === 'cassandra') { _%>
         user.setId(UUID.randomUUID().toString());
         <%_ } _%>
@@ -150,7 +150,7 @@ public class UserJWTControllerIntTest <% if (databaseType === 'cassandra') { %>e
     @Transactional
     <%_ } _%>
     public void testAuthorizeWithRememberMe() throws Exception {
-        User user = new User();
+        <%= asEntity('User') %> user = new <%= asEntity('User') %>();
         <%_ if (databaseType === 'cassandra') { _%>
         user.setId(UUID.randomUUID().toString());
         <%_ } _%>
diff --git a/generators/server/templates/src/test/java/package/web/rest/UserResourceIntTest.java.ejs b/generators/server/templates/src/test/java/package/web/rest/UserResourceIntTest.java.ejs
index abb7b44fb5..069155524d 100644
--- a/generators/server/templates/src/test/java/package/web/rest/UserResourceIntTest.java.ejs
+++ b/generators/server/templates/src/test/java/package/web/rest/UserResourceIntTest.java.ejs
@@ -28,7 +28,7 @@ import <%= packageName %>.config.ReactivePageableHandlerMethodArgumentResolver;
 <%_ if (databaseType !== 'cassandra' && databaseType !== 'couchbase') { _%>
 import <%= packageName %>.domain.Authority;
 <%_ } _%>
-import <%= packageName %>.domain.User;
+import <%= packageName %>.domain.<%= asEntity('User') %>;
 import <%= packageName %>.repository<% if (reactive) { %>.reactive<% } %>.UserRepository;
 <%_ if (searchEngine === 'elasticsearch') { _%>
 import <%= packageName %>.repository.search.UserSearchRepository;
@@ -37,7 +37,7 @@ import <%= packageName %>.security.AuthoritiesConstants;
 <%_ if (authenticationType !== 'oauth2') { _%>
 import <%= packageName %>.service.MailService;<% } %>
 import <%= packageName %>.service.UserService;
-import <%= packageName %>.service.dto.UserDTO;
+import <%= packageName %>.service.dto.<%= asDto('User') %>;
 import <%= packageName %>.service.mapper.UserMapper;
 import <%= packageName %>.web.rest.errors.ExceptionTranslator;
 <%_ if (authenticationType !== 'oauth2') { _%>
@@ -116,7 +116,7 @@ public class UserResourceIntTest <% if (databaseType === 'cassandra') { %>extend
     <%_ if (databaseType === 'sql' && authenticationType !== 'oauth2') { _%>
     private static final Long DEFAULT_ID = 1L;
     <%_ } else if (databaseType === 'couchbase'){ _%>
-    private static final String DEFAULT_ID = User.PREFIX + DEFAULT_LOGIN;
+    private static final String DEFAULT_ID = <%= asEntity('User') %>.PREFIX + DEFAULT_LOGIN;
     <%_ } else { _%>
     private static final String DEFAULT_ID = "id1";
     <%_ } _%>
@@ -204,7 +204,7 @@ public class UserResourceIntTest <% if (databaseType === 'cassandra') { %>extend
     private MockMvc restUserMockMvc;
     <%_ } _%>
 
-    private User user;
+    private <%= asEntity('User') %> user;
 
     @Before
     public void setup() {
@@ -233,8 +233,8 @@ public class UserResourceIntTest <% if (databaseType === 'cassandra') { %>extend
      * This is a static method, as tests for other entities might also need it,
      * if they test an entity which has a required relationship to the User entity.
      */
-    public static User createEntity(<% if (databaseType === 'sql') { %>EntityManager em<% } %>) {
-        User user = new User();
+    public static <%= asEntity('User') %> createEntity(<% if (databaseType === 'sql') { %>EntityManager em<% } %>) {
+        <%= asEntity('User') %> user = new <%= asEntity('User') %>();
         <%_ if (databaseType === 'cassandra' || (authenticationType === 'oauth2' && databaseType !== 'couchbase')) { _%>
         user.setId(UUID.randomUUID().toString());
         <%_ } _%>
@@ -306,9 +306,9 @@ public class UserResourceIntTest <% if (databaseType === 'cassandra') { %>extend
         <%_ } _%>
 
         // Validate the User in the database
-        List<User> userList = userRepository.findAll()<% if (reactive) { %>.collectList().block()<% } %>;
+        List<<%= asEntity('User') %>> userList = userRepository.findAll()<% if (reactive) { %>.collectList().block()<% } %>;
         assertThat(userList).hasSize(databaseSizeBeforeCreate + 1);
-        User testUser = userList.get(userList.size() - 1);
+        <%= asEntity('User') %> testUser = userList.get(userList.size() - 1);
         assertThat(testUser.getLogin()).isEqualTo(DEFAULT_LOGIN);
         assertThat(testUser.getFirstName()).isEqualTo(DEFAULT_FIRSTNAME);
         assertThat(testUser.getLastName()).isEqualTo(DEFAULT_LASTNAME);
@@ -362,7 +362,7 @@ public class UserResourceIntTest <% if (databaseType === 'cassandra') { %>extend
         <%_ } _%>
 
         // Validate the User in the database
-        List<User> userList = userRepository.findAll()<% if (reactive) { %>.collectList().block()<% } %>;
+        List<<%= asEntity('User') %>> userList = userRepository.findAll()<% if (reactive) { %>.collectList().block()<% } %>;
         assertThat(userList).hasSize(databaseSizeBeforeCreate);
     }
 
@@ -407,7 +407,7 @@ public class UserResourceIntTest <% if (databaseType === 'cassandra') { %>extend
         <%_ } _%>
 
         // Validate the User in the database
-        List<User> userList = userRepository.findAll()<% if (reactive) { %>.collectList().block()<% } %>;
+        List<<%= asEntity('User') %>> userList = userRepository.findAll()<% if (reactive) { %>.collectList().block()<% } %>;
         assertThat(userList).hasSize(databaseSizeBeforeCreate);
     }
 
@@ -452,7 +452,7 @@ public class UserResourceIntTest <% if (databaseType === 'cassandra') { %>extend
         <%_ } _%>
 
         // Validate the User in the database
-        List<User> userList = userRepository.findAll()<% if (reactive) { %>.collectList().block()<% } %>;
+        List<<%= asEntity('User') %>> userList = userRepository.findAll()<% if (reactive) { %>.collectList().block()<% } %>;
         assertThat(userList).hasSize(databaseSizeBeforeCreate);
     }
 <%_ } _%>
@@ -483,12 +483,12 @@ public class UserResourceIntTest <% if (databaseType === 'cassandra') { %>extend
             <%_ } _%>
             .andExpect(jsonPath("$.[*].langKey").value(hasItem(DEFAULT_LANGKEY)));
         <%_ } else { _%>
-        UserDTO foundUser = webTestClient.get().uri("/api/users?sort=createdDate,DESC")
+        <%= asDto('User') %> foundUser = webTestClient.get().uri("/api/users?sort=createdDate,DESC")
             .accept(MediaType.APPLICATION_JSON)
             .exchange()
             .expectStatus().isOk()
             .expectHeader().contentType(MediaType.APPLICATION_JSON_UTF8)
-            .returnResult(UserDTO.class).getResponseBody().blockFirst();
+            .returnResult(<%= asDto('User') %>.class).getResponseBody().blockFirst();
 
         assertThat(foundUser.getLogin()).isEqualTo(DEFAULT_LOGIN);
         assertThat(foundUser.getFirstName()).isEqualTo(DEFAULT_FIRSTNAME);
@@ -576,7 +576,7 @@ public class UserResourceIntTest <% if (databaseType === 'cassandra') { %>extend
             .collectList().block()<% } %>.size();
 
         // Update the user
-        User updatedUser = userRepository.findById(user.getId()).<% if (reactive) { %>block<% } else { %>get<% } %>();
+        <%= asEntity('User') %> updatedUser = userRepository.findById(user.getId()).<% if (reactive) { %>block<% } else { %>get<% } %>();
 
         ManagedUserVM managedUserVM = new ManagedUserVM();
         managedUserVM.setId(updatedUser.getId());
@@ -612,9 +612,9 @@ public class UserResourceIntTest <% if (databaseType === 'cassandra') { %>extend
         <%_ } _%>
 
         // Validate the User in the database
-        List<User> userList = userRepository.findAll()<% if (reactive) { %>.collectList().block()<% } %>;
+        List<<%= asEntity('User') %>> userList = userRepository.findAll()<% if (reactive) { %>.collectList().block()<% } %>;
         assertThat(userList).hasSize(databaseSizeBeforeUpdate);
-        User testUser = userList.get(userList.size() - 1);
+        <%= asEntity('User') %> testUser = userList.get(userList.size() - 1);
         assertThat(testUser.getFirstName()).isEqualTo(UPDATED_FIRSTNAME);
         assertThat(testUser.getLastName()).isEqualTo(UPDATED_LASTNAME);
         assertThat(testUser.getEmail()).isEqualTo(UPDATED_EMAIL);
@@ -638,7 +638,7 @@ public class UserResourceIntTest <% if (databaseType === 'cassandra') { %>extend
             .collectList().block()<% } %>.size();
 
         // Update the user
-        User updatedUser = userRepository.findById(user.getId()).<% if (reactive) { %>block<% } else { %>get<% } %>();
+        <%= asEntity('User') %> updatedUser = userRepository.findById(user.getId()).<% if (reactive) { %>block<% } else { %>get<% } %>();
 
         ManagedUserVM managedUserVM = new ManagedUserVM();
         managedUserVM.setId(updatedUser.getId());
@@ -674,9 +674,9 @@ public class UserResourceIntTest <% if (databaseType === 'cassandra') { %>extend
         <%_ } _%>
 
         // Validate the User in the database
-        List<User> userList = userRepository.findAll()<% if (reactive) { %>.collectList().block()<% } %>;
+        List<<%= asEntity('User') %>> userList = userRepository.findAll()<% if (reactive) { %>.collectList().block()<% } %>;
         assertThat(userList).hasSize(databaseSizeBeforeUpdate);
-        User testUser = userList.get(userList.size() - 1);
+        <%= asEntity('User') %> testUser = userList.get(userList.size() - 1);
         assertThat(testUser.getLogin()).isEqualTo(UPDATED_LOGIN);
         assertThat(testUser.getFirstName()).isEqualTo(UPDATED_FIRSTNAME);
         assertThat(testUser.getLastName()).isEqualTo(UPDATED_LASTNAME);
@@ -698,7 +698,7 @@ public class UserResourceIntTest <% if (databaseType === 'cassandra') { %>extend
         mockUserSearchRepository.save(user);
         <%_ } _%>
 
-        User anotherUser = new User();
+        <%= asEntity('User') %> anotherUser = new <%= asEntity('User') %>();
         <%_ if (databaseType === 'cassandra') { _%>
         anotherUser.setId(UUID.randomUUID().toString());
         <%_ } _%>
@@ -718,7 +718,7 @@ public class UserResourceIntTest <% if (databaseType === 'cassandra') { %>extend
         <%_ } _%>
 
         // Update the user
-        User updatedUser = userRepository.findById(user.getId()).<% if (reactive) { %>block<% } else { %>get<% } %>();
+        <%= asEntity('User') %> updatedUser = userRepository.findById(user.getId()).<% if (reactive) { %>block<% } else { %>get<% } %>();
 
         ManagedUserVM managedUserVM = new ManagedUserVM();
         managedUserVM.setId(updatedUser.getId());
@@ -765,7 +765,7 @@ public class UserResourceIntTest <% if (databaseType === 'cassandra') { %>extend
         mockUserSearchRepository.save(user);
         <%_ } _%>
 
-        User anotherUser = new User();
+        <%= asEntity('User') %> anotherUser = new <%= asEntity('User') %>();
         <%_ if (databaseType === 'cassandra') { _%>
         anotherUser.setId(UUID.randomUUID().toString());
         <%_ } _%>
@@ -785,7 +785,7 @@ public class UserResourceIntTest <% if (databaseType === 'cassandra') { %>extend
         <%_ } _%>
 
         // Update the user
-        User updatedUser = userRepository.findById(user.getId()).<% if (reactive) { %>block<% } else { %>get<% } %>();
+        <%= asEntity('User') %> updatedUser = userRepository.findById(user.getId()).<% if (reactive) { %>block<% } else { %>get<% } %>();
 
         ManagedUserVM managedUserVM = new ManagedUserVM();
         managedUserVM.setId(updatedUser.getId());
@@ -851,7 +851,7 @@ public class UserResourceIntTest <% if (databaseType === 'cassandra') { %>extend
         <%_ } _%>
 
         // Validate the database is empty
-        List<User> userList = userRepository.findAll()<% if (reactive) { %>.collectList().block()<% } %>;
+        List<<%= asEntity('User') %>> userList = userRepository.findAll()<% if (reactive) { %>.collectList().block()<% } %>;
         assertThat(userList).hasSize(databaseSizeBeforeDelete - 1);
     }
     <%_ } _%>
@@ -890,10 +890,10 @@ public class UserResourceIntTest <% if (databaseType === 'cassandra') { %>extend
     @Transactional
     <%_ } _%>
     public void testUserEquals() throws Exception {
-        TestUtil.equalsVerifier(User.class);
-        User user1 = new User();
+        TestUtil.equalsVerifier(<%= asEntity('User') %>.class);
+        <%= asEntity('User') %> user1 = new <%= asEntity('User') %>();
         user1.setId(<% if (databaseType === 'sql' && authenticationType !== 'oauth2') { %>1L<% } else { %>"id1"<% } %>);
-        User user2 = new User();
+        <%= asEntity('User') %> user2 = new <%= asEntity('User') %>();
         user2.setId(user1.getId());
         assertThat(user1).isEqualTo(user2);
         user2.setId(<% if (databaseType === 'sql' && authenticationType !== 'oauth2') { %>2L<% } else { %>"id2"<% } %>);
@@ -904,7 +904,7 @@ public class UserResourceIntTest <% if (databaseType === 'cassandra') { %>extend
 
     @Test
     public void testUserDTOtoUser() {
-        UserDTO userDTO = new UserDTO();
+        <%= asDto('User') %> userDTO = new <%= asDto('User') %>();
         userDTO.setId(DEFAULT_ID);
         userDTO.setLogin(DEFAULT_LOGIN);
         userDTO.setFirstName(DEFAULT_FIRSTNAME);
@@ -921,7 +921,7 @@ public class UserResourceIntTest <% if (databaseType === 'cassandra') { %>extend
         <%_ } _%>
         userDTO.setAuthorities(Collections.singleton(AuthoritiesConstants.USER));
 
-        User user = userMapper.userDTOToUser(userDTO);
+        <%= asEntity('User') %> user = userMapper.userDTOToUser(userDTO);
         assertThat(user.getId()).isEqualTo(DEFAULT_ID);
         assertThat(user.getLogin()).isEqualTo(DEFAULT_LOGIN);
         assertThat(user.getFirstName()).isEqualTo(DEFAULT_FIRSTNAME);
@@ -960,7 +960,7 @@ public class UserResourceIntTest <% if (databaseType === 'cassandra') { %>extend
         user.setAuthorities(Stream.of(AuthoritiesConstants.USER).collect(Collectors.toSet()));
         <%_ } _%>
 
-        UserDTO userDTO = userMapper.userToUserDTO(user);
+        <%= asDto('User') %> userDTO = userMapper.userToUserDTO(user);
 
         assertThat(userDTO.getId()).isEqualTo(DEFAULT_ID);
         assertThat(userDTO.getLogin()).isEqualTo(DEFAULT_LOGIN);
diff --git a/test-integration/samples/ngx-default/.yo-rc.json b/test-integration/samples/ngx-default/.yo-rc.json
index c55b0429e3..36507ad0a4 100644
--- a/test-integration/samples/ngx-default/.yo-rc.json
+++ b/test-integration/samples/ngx-default/.yo-rc.json
@@ -65,6 +65,8 @@
         "messageBroker": false,
         "serviceDiscoveryType": false,
         "clientPackageManager": "npm",
-        "clientFramework": "angularX"
+        "clientFramework": "angularX",
+        "entitySuffix": "Entity",
+        "dtoSuffix": ""
     }
 }
diff --git a/test/entity.spec.js b/test/entity.spec.js
index 2dbd334ed1..c86bc2388e 100644
--- a/test/entity.spec.js
+++ b/test/entity.spec.js
@@ -36,6 +36,96 @@ describe('JHipster generator for entity', () => {
         });
     });
 
+    context('monolith with entity and dto suffixes', () => {
+        describe('with entity and dto suffixes', () => {
+            beforeEach(done => {
+                helpers
+                    .run(require.resolve('../generators/entity'))
+                    .inTmpDir(dir => {
+                        fse.copySync(path.join(__dirname, '../test/templates/entity-dto-suffixes'), dir);
+                    })
+                    .withArguments(['foo'])
+                    .withPrompts({
+                        fieldAdd: false,
+                        relationshipAdd: false,
+                        dto: 'mapstruct',
+                        service: 'serviceImpl'
+                    })
+                    .on('end', done);
+            });
+
+            it('creates expected files with suffix', () => {
+                assert.file([
+                    '.jhipster/Foo.json',
+                    `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/domain/FooXXX.java`,
+                    `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/repository/FooRepository.java`,
+                    `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/web/rest/FooResource.java`,
+                    `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/service/dto/FooYYY.java`,
+                    `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/service/mapper/FooMapper.java`,
+                    `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/service/FooService.java`
+                ]);
+
+                assert.fileContent(
+                    `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/repository/FooRepository.java`,
+                    'public interface FooRepository '
+                );
+
+                assert.fileContent(
+                    `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/domain/FooXXX.java`,
+                    'public class FooXXX implements Serializable'
+                );
+
+                assert.fileContent(
+                    `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/service/dto/FooYYY.java`,
+                    'public class FooYYY implements Serializable'
+                );
+            });
+        });
+
+        describe('with entity suffix and no dto', () => {
+            beforeEach(done => {
+                helpers
+                    .run(require.resolve('../generators/entity'))
+                    .inTmpDir(dir => {
+                        fse.copySync(path.join(__dirname, '../test/templates/entity-dto-suffixes'), dir);
+                    })
+                    .withArguments(['foo'])
+                    .withPrompts({
+                        fieldAdd: false,
+                        relationshipAdd: false,
+                        dto: 'no',
+                        service: 'serviceImpl'
+                    })
+                    .on('end', done);
+            });
+
+            it('creates expected files with suffix', () => {
+                assert.file([
+                    '.jhipster/Foo.json',
+                    `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/domain/FooXXX.java`,
+                    `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/repository/FooRepository.java`,
+                    `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/web/rest/FooResource.java`,
+                    `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/service/FooService.java`
+                ]);
+
+                assert.noFile([
+                    `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/service/dto/FooYYY.java`,
+                    `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/service/mapper/FooMapper.java`
+                ]);
+
+                assert.fileContent(
+                    `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/repository/FooRepository.java`,
+                    'public interface FooRepository '
+                );
+
+                assert.fileContent(
+                    `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/domain/FooXXX.java`,
+                    'public class FooXXX implements Serializable'
+                );
+            });
+        });
+    });
+
     context('monolith with angularX', () => {
         describe('no dto, no service, no pagination', () => {
             before(done => {
diff --git a/test/templates/entity-dto-suffixes/.yo-rc.json b/test/templates/entity-dto-suffixes/.yo-rc.json
new file mode 100644
index 0000000000..2d10a5034f
--- /dev/null
+++ b/test/templates/entity-dto-suffixes/.yo-rc.json
@@ -0,0 +1,29 @@
+{
+  "generator-jhipster": {
+    "applicationType": "monolith",
+    "baseName": "sampleMysql",
+    "packageName": "com.mycompany.myapp",
+    "packageFolder": "com/mycompany/myapp",
+    "authenticationType": "session",
+    "cacheProvider": "ehcache",
+    "websocket": "no",
+    "databaseType": "sql",
+    "devDatabaseType": "h2Disk",
+    "prodDatabaseType": "mysql",
+    "searchEngine": "no",
+    "useSass": false,
+    "buildTool": "maven",
+    "enableTranslation": true,
+    "nativeLanguage": "en",
+    "languages": [
+      "en",
+      "fr"
+    ],
+    "rememberMeKey": "2bb60a80889aa6e6767e9ccd8714982681152aa5",
+    "testFrameworks": [
+      "gatling"
+    ],
+    "entitySuffix": "XXX",
+    "dtoSuffix": "YYY"
+  }
+}