I defined my model classes like below.
@Entity
@Table(name = "my_employee")
public class Employee {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private int id;
    private String name;
    @OneToMany(cascade = CascadeType.ALL)
    @JoinTable(name = "emp_address_mapping", joinColumns = @JoinColumn(name = "emp_id"), inverseJoinColumns = @JoinColumn(name = "address_id"))
    private List<Address> addresses = new ArrayList<Address>();
    .......
    .......
}
@Entity
@Table(name = "my_address")
public class Address {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private int id;
    private String country;
    .....
    .....
}
public class EmployeeDetails {
    private int empId;
    private String name;
    private String country;
    ......
    ......
}
How can I write a query using @Query annotation to populate all the EmployeeDetails.
public interface EmployeeRepository extends CrudRepository<Employee, Integer> {
    @Query("SELECT new com.sample.app.model.EmployeeDetails......")
    List<EmployeeDetails> getEmployeeDetails();
}
 
    