Skip to content
This repository was archived by the owner on Sep 24, 2025. It is now read-only.

Conversation

@donggyu04
Copy link
Contributor

@donggyu04 donggyu04 commented Oct 8, 2020

Currently, we are using the SecuredUser object as a spring security's authentication principal.
It is used in some of our codes.

case of below, It emits lazy initialize exception(no session).
because the User object stored in SecuredUser at login time is not properly initialized the fields that require lazy fetch.

so, I changed a SecuredUser to have eager fetched user object at login time.

SecuredUser secureUser = cast(authentication.getPrincipal());
User user = secureUser.getUser();

...

// Emit lazy initialize exception (no session)
List<User> owners = user.getOwners();

Code snippet link

@donggyu04 donggyu04 self-assigned this Oct 8, 2020
@donggyu04 donggyu04 force-pushed the bugfix/prevent-lazy-initialize-exception-at-secured-user branch 2 times, most recently from 6f33d82 to afa1e76 Compare October 8, 2020 10:14
imbyungjun
imbyungjun previously approved these changes Oct 8, 2020
@donggyu04 donggyu04 force-pushed the bugfix/prevent-lazy-initialize-exception-at-secured-user branch from afa1e76 to 4b605a1 Compare October 8, 2020 10:20
songeunwoo
songeunwoo previously approved these changes Oct 15, 2020
@donggyu04 donggyu04 force-pushed the bugfix/prevent-lazy-initialize-exception-at-secured-user branch from 4b605a1 to 5ef4511 Compare October 22, 2020 10:15
@imbyungjun imbyungjun merged commit aba46f5 into develop Oct 27, 2020
@donggyu04 donggyu04 deleted the bugfix/prevent-lazy-initialize-exception-at-secured-user branch October 29, 2020 15:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants