2023-04-06

[Solved] - LazyInitializationException: could not initialize proxy

 


org.hibernate.LazyInitializationException: could not initialize proxy [com.yourcompany.entity.Table#123456] - no Session


relevant tags:
  1. Spring Boot 2.7.6
  2. JUnit 5
  3. JPA

Resolved by both below:

1. Adding annotation below to your test function:
Reference URL: https://stackoverflow.com/a/72863346/6462295
@org.springframework.transaction.annotation.Transactional(readOnly = true)





2. Adding configuration into application.properties
Reference URL: https://stackoverflow.com/a/38690930/6462295

spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true






No comments:

Post a Comment