0

Famous threads like LazyInitializationException with Spring Data JpaRepositories mention many solutions to LazyInitializationException but do not mention reattaching the detached entity to a (new?) session when you want to lazy load the rest of the associated entities.

Is that because it can't happen ? If it is possible why isn't it mentioned as an alternative?

Most importantly how can you do that with Spring Data Jpa? Do you need to call the underlying Hibernate update() call in order to reattach? And as with Spring to which session do you attach if the session has already been closed after a Service call to the Repository? do you span a new session by calling into the repository again and with which JPA construct/command?

microwth
  • 730
  • 1
  • 11
  • 24

0 Answers0