As explained in the forum thread, and using the Pet entity as an example, the controller code generated by Roo calls findAllPets() upon every request, thanks to the presence of this method:
This is wasteful given that:
- Some of the controller's request handling methods (e.g. "show" and "delete") don't even use the returned list of Pets.
- The "list" method obtains its own list of Pets (usually via findPetEntries()).
- The "create*" and "update*" methods only need the list of all Pets if the Pet class has a Pet (or Pets) field.
We can make the scaffolded controllers more performant by only obtaining the list of all Pets when it's actually required.
In the meantime, the workaround is as follows:
- Push in the populatePets method and have it return null (saves time in the "list" method)
- If the entity has a field of its own type (or a collection thereof), push in the "create*" and "update*" methods and modify them to explicitly put the "pets" list into the model, for example (showing the create* methods):