I have entity class User with composite key via @IdClass annotation
@Entity
@IdClass(UserId.class)
public class User {
@Id
private String name;
@Id
private String surname;
private boolean active;
}
Composite key:
@Data
public class UserId implements Serializable {
private String name;
private String surname;
}
I use Spring Data with hibernate JPA under hood. Therefore I have repo interface:
public interface UserRepo extends JpaRepository<User, UserId> {
}
And I'd like to get all active users from db by list of concrete names and surnames. E.g. I'd like to use method like this
List<User> findAllByActiveTrue(List<UserId> ids);
How can I do query for this requirement via Spring Data or JPQL?