I am using spring-data-jpa.
I would to like to know when is the session of jpa will be closed ?
Here is my case:
I have a main thread and in that thread I invoked the getOne(Long id) method of the UserService class. The implement of the getOne method of UserService like common method is invoked the findById(Long id) method of userRepository.
After I got an User entity from the method I startd a thread by async And In the run method of that thread I invoked the A(User user) method with the user entity as the argument of that method.
In the A(User user) method called the getPosts() method of the user entity to get the posts field of the User entity. But I got an exception from jpa hibernate during I call the getPosts() method.
The field posts of user entity is one to many relationship And that is load by lazy.
I know I trigged the lazy load when I called the getPosts() method.
The exception says the session was closed.
Before ask how to fix this error I also would like to know when is the jpa session will be closed ?
I know no code no error details is bad ask a question at here but I am not able to use my computer at this time and I am so interested about this question So please forgive me If I am able to use my computer I will update my post.
Thanks you all.