Skip to content

After upgrading to spring-boot 3.2 I get LazyInitializationException #3724

Closed as not planned
@Arsenii01

Description

@Arsenii01

Hello. My project was using spring boot 3.1.12, and I upgraded version to 3.2.0, but I started getting org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: could not initialize proxy - no Session when trying to access child entities of my parent entity.

spring-boot-starter-jpa:3.2.0 uses Hibernate 6.3, in migration guide there is a paragraph 'Batch Fetching and LockMode', maybe this new behavor is the cause of my problem. How can I fix it, if I use Spring Data JPA? My method is annotated with @Transactional and it worked fine before

@EntityGraph is not an option because it increases endpoint response time too much, the same goes for fetch join query (Hibernate will make 2 fetch joins in query for each parent entity, of which there may be many)

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: stackoverflowA question that's better suited to stackoverflow.com

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions