diff --git a/generators/spring-boot/templates/src/main/java/_package_/_entityPackage_/_partials_entity_/get_all_template.ejs b/generators/spring-boot/templates/src/main/java/_package_/_entityPackage_/_partials_entity_/get_all_template.ejs index 9d6472a62d4d..68257f8a146c 100644 --- a/generators/spring-boot/templates/src/main/java/_package_/_entityPackage_/_partials_entity_/get_all_template.ejs +++ b/generators/spring-boot/templates/src/main/java/_package_/_entityPackage_/_partials_entity_/get_all_template.ejs @@ -78,7 +78,11 @@ _%> public <% if (reactive) { %>Mono<<% } %>List<<%= instanceType %>><% if (reactive) { %>><% } %> getAll<%= entityClassPlural %>(<% if (fieldsContainNoOwnerOneToOne) { %>@RequestParam(name = "filter", required = false) String filter<% } %><% if (implementsEagerLoadApis && fieldsContainNoOwnerOneToOne) { %>,<% } %><% if (implementsEagerLoadApis) { %>@RequestParam(name = "eagerload", required = false, defaultValue = "true") boolean eagerload<% } %>) {<%- include('get_all_stream_template', {viaService: viaService}); -%> log.debug("REST request to get all <%= entityClassPlural %>"); <%_ if (viaService) { _%> - return <%= entityInstance %>Service.findAll()<% if (reactive) { %>.collectList()<% } %>; + <% if (implementsEagerLoadApis && !dtoMapstruct) { %> + return <%= entityInstance %>Repository.findAllWithEagerRelationships()<% if (reactive) { %>.collectList()<% } %>; + <%_ } else { _%> + return <%= entityInstance %>Service.findAll(<% if (implementsEagerLoadApis) { %>eagerload<% } %>)<% if (reactive) { %>.collectList()<% } %>; + <%_ } _%> <%_ } else if (dtoMapstruct) { _%> <%= reactive ? 'Flux' : 'List' %><<%= persistClass %>> <%= entityInstancePlural %> = <%= entityInstance %>Repository.findAll(); <%_ if (reactive) { _%>