title: Spring data jpa How to filter the child objects of the result？
body: <p>Spring data jpa How to filter the child objects of the result？</p>
  
  <pre><code>@Entity
  public class Player {
  
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private Integer id;
  
  private String name;
  
  @OneToMany(mappedBy = "player")
  private List&lt;PlayerItem&gt; playerItems;
  
  public Integer getId() {
      return id;
  }
  
  public void setId(Integer id) {
      this.id = id;
  }
  
  public String getName() {
      return name;
  }
  
  public void setName(String name) {
      this.name = name;
  }
  
  public List&lt;PlayerItem&gt; getPlayerItems() {
      return playerItems;
  }
  
  public void setPlayerItems(List&lt;PlayerItem&gt; playerItems) {
      this.playerItems = playerItems;
  }
  }
  
  @Entity
  public class PlayerItem {
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private Integer id;
  
  private String name;
  
  private Boolean begin;
  
  @ManyToOne
  @JoinColumn(name = "play_id")
  @JsonIgnore
  private Player player;
  
  public Integer getId() {
      return id;
  }
  
  public void setId(Integer id) {
      this.id = id;
  }
  
  public String getName() {
      return name;
  }
  
  public void setName(String name) {
      this.name = name;
  }
  
  public Boolean getBegin() {
      return begin;
  }
  
  public void setBegin(Boolean begin) {
      this.begin = begin;
  }
  
  public Player getPlayer() {
      return player;
  }
  
  public void setPlayer(Player player) {
      this.player = player;
  }
  }
  
  public interface PlayerRepository extends JpaRepository&lt;Player, Integer&gt; {
  List&lt;Player&gt; findByPlayerItemsName(String name);
  }
  
  @RestController
  public class TestQcController {
  @Resource
  PlayerRepository repository;
  
  @PostMapping("test")
  public Object testQc() {
      List&lt;Player&gt; players = repository.findByPlayerItemsName("dada");
      return players;
  }
  }
  </code></pre>
  
  <p>JSON result</p>
  
  <pre><code>[{
      "id": 1,
      "name": "haha",
      "playerItems": [{
          "id": 1,
          "name": "dada",
          "begin": false
      }, {
          "id": 2,
          "name": "wawa",
          "begin": true
      }]
  }]
  </code></pre>
  
  <p>Expected ：</p>
  
  <pre><code>[{
      "id": 1,
      "name": "haha",
      "playerItems": [{
          "id": 1,
          "name": "dada",
          "begin": false
      }]
  }]
  </code></pre>
  
  <p>actual：</p>
  
  <pre><code>[{
      "id": 1,
      "name": "haha",
      "playerItems": [{
          "id": 1,
          "name": "dada",
          "begin": false
      }, {
          "id": 2,
          "name": "wawa",
          "begin": true
      }]
  }]
  </code></pre>