'Select rows using mapping table with JPA

I do not know how to implement the query below in jpa, so please help.

select t.*
from team t
join team_memeber tm
  on t.team_id = tm.team_id and tm.member_id = ?

The related entities are as follows.

public class Team {
  @Id
  int teamId;

  @OneToMany(fetch = FetchType.LAZY)
  @JoinColumn(name = "teamId")
  Set<TeamMember> members = new HashSet<>();
}
public class TeamMember {
  @Id
  int id;

  int teamId;

  int memberId;
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source