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 ff9e61a507f3..6d5bfc5d84a1 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 @@ -42,14 +42,14 @@ if (!viaService) { resultEntity = asEntity(entityInstance); _%> <%= asEntity(entityClass) %> <%= asEntity(entityInstance) %> = <%= dtoToEntity %>(<%= instanceName %>); <%_ if (isUsingMapsId === true) { _%> - long <%= otherEntityName %>Id = <%= instanceName %>.get<%= mapsIdAssoc.relationshipNameCapitalized %>Id(); + <%= pkType %> <%= otherEntityName %>Id = <%= instanceName %>.get<%= mapsIdAssoc.relationshipNameCapitalized %>Id(); <%= mapsIdRepoInstance %>.findById(<%= otherEntityName %>Id).ifPresent(<%= entityInstance%>::<%= otherEntityName %>); <%_ } _%> <%= asEntity(entityInstance) %> = <%= entityInstance %>Repository.save(<%= asEntity(entityInstance) %>); <%= returnPrefix %> <%= entityToDto %>(<%= asEntity(entityInstance) %>); <%_ } else { resultEntity = 'result'; _%> <%_ if (isUsingMapsId === true) { _%> - long <%= otherEntityName %>Id = <%= instanceName %>.get<%= mapsIdAssoc.relationshipNameCapitalized %>().getId(); + <%= pkType %> <%= otherEntityName %>Id = <%= instanceName %>.get<%= mapsIdAssoc.relationshipNameCapitalized %>().getId(); <%= mapsIdRepoInstance %>.findById(<%= otherEntityName %>Id).ifPresent(<%= instanceName%>::<%= otherEntityName %>); <%_ } _%> <%= returnPrefix %> <%= entityInstance %>Repository.save(<%= asEntity(entityInstance) %>); @@ -59,7 +59,7 @@ if (!viaService) { return result; <%_ }}} else { _%> <%_ if (isUsingMapsId === true && isController === false) { _%> - long <%= otherEntityName %>Id = <%= entityInstance %>.get<%= mapsIdAssoc.relationshipNameCapitalized %>().getId(); + <%= pkType %> <%= otherEntityName %>Id = <%= entityInstance %>.get<%= mapsIdAssoc.relationshipNameCapitalized %>().getId(); <%= mapsIdRepoInstance %>.findById(<%= otherEntityName %>Id).ifPresent(<%= entityInstance%>::<%= otherEntityName %>); <%_ } _%> <%= returnPrefix %> <%= entityInstance %>Service.save(<%= instanceName %>);