Code Room
Code reviewMediumcr-g205
Subject N plus oneLevel Mid–Senior~25 minCommon in Code quality & review interviewsIndustries Software development

Question

Review this Java (JPA/Hibernate) service method.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.

Talk through your review
Code to reviewjava
@Transactional(readOnly = true)public List<TeamDto> activeTeams() {    List<Team> teams = em.createQuery(        "SELECT t FROM Team t WHERE t.active = true", Team.class)        .getResultList();    return teams.stream().map(t -> new TeamDto(        t.getName(),        t.getMembers().size(),            // members is @OneToMany(fetch = LAZY)        t.getLead().getEmail()            // lead is @ManyToOne(fetch = LAZY)    )).collect(Collectors.toList());}
Run or narrate your approach, then ask the coach.