Skip to main content
3 of 4
Formatted/Indented the question.

Spring Data, JPA @OneToMany Lazy fetch not working in Spring Boot

I have @OneToMany relationship between FabricRoll and FabricDefect.

@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @JoinColumn(name = "fabric_roll_id", referencedColumnName = "fabric_roll_id") private Set<FabricDefect> fabricDefects = new HashSet<>(); 

The problem is when I get FabricRoll by JpaRepository function

findAll()

the associate FabricDefect is also loaded.

I want to load only FabricRoll and FabricDefect should load when calling the function getFabricDefect()

Atekur Rahman
  • 301
  • 1
  • 4
  • 11