@BatchSize
is a Hibernate-specific annotation that optimizes the N+1 query problem by fetching lazy-loaded associations in batches rather than one at a time, then you can optimize as:
@OneToMany(mappedBy = "courses", fetch = FetchType.LAZY)
@BatchSize(size = 25)
private Set<CourseModules> courseModules = new HashSet<>();