I don't look every time a user in Spring?

In General, whenever the controller in the Spring I have to look for the user to create object and work with it. Ie let's say I go to /profile, I get the name of the authenticated user, looking for it, if it's okay to work with him. Click for /index, you again have to look for the user in the database, create an object and again, build the page for him. How to avoid search and create a new object?
July 9th 19 at 13:24
1 answer
July 9th 19 at 13:26
If you are using Spring Security then the current authenticated user is in the SecurityContextHolder, we get it:
(UserWrapper) SecurityContextHolder.getContext().getAuthentication().getPrincipal()

Find more questions by tags JavaSpring