All the controllers must be cleaned up.
They must not contain any dao injection.
Also, any related to the service tasks must be moved from controllers to the services:
Account Controller :
if (account != null) {
final UserDetails owner = userRepositoryDaoImpl.findByUserUsername(getSessionUser().getUsername());
account.setOwner(owner);
accountRepositoryDaoImpl.save(account);
the owner must be set in the service.
Controllers must not now how to create and initialize objects, they must ask services to do so:
UserDetails userDetails = new UserDetails();
UserRole aUserRole = new UserRole();
aUserRole.setUserRole(UserRole.Role.USER_ROLE);
model.addAttribute(userDetails);
return "registration";
new User must be created in the appropriate controller.
All the controllers must be cleaned up. They must not contain any dao injection. Also, any related to the service tasks must be moved from controllers to the services: Account Controller :
the owner must be set in the service.
Controllers must not now how to create and initialize objects, they must ask services to do so:
new User must be created in the appropriate controller.
Clean all the related bugs in the controllers.