我有一个名为MatchStats的实体,我想检索一个matchstats列表,其中在“下注者”列表中有一个用户名为“ somthing” /punter.player.userName=“ something”的下注者。这是组成matchstats的以下三个实体
public class MatchStats extends DefaultEntity {
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
private List<Punter> punters;
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
private List<Punter> winners;
private double winning_amount;
}
打孔实体
@Entity
@Table(name = "Punter")
public class Punter extends DefaultEntity {
@Valid
@ManyToOne(targetEntity = User.class)
@JoinColumn(name="player")
private User player;
@NotBlank
private double risk;
}
用户实体
@Entity
@Table(name = "Users")
public class User extends DefaultEntity {
@Column(name = "FirstName")
@NotNull(message = "Enter a FirstName")
private String firstName;
@Column(name = "LastName")
@NotBlank(message = "Enter a LastName")
private String lastName;
@Column(unique = true,name = "UserName")
@NotBlank(message = "Enter a UserName")
private String userName;
}
我希望springJpa会有这样的东西
Page<MatchStats> getAllByPuntersPlayer(User user, Pageable pageable);
但是我认为这是不可能的,有没有办法实现这一目标?