2017-12-10 21 views
0

私はスプリングデータでスプリングブートアプリケーションを使用していますSolrCrudrepositoryを使用しています。私はProductと呼ばれるエンティティを持っています。これはSolrに製品情報を格納するために使用されます。私の質問は、ProductreposiroryからすべてのProductIDを取得したいのです。 ProductContentのリストを返すfindAll()を使うことができますが、productidであるListだけが必要です。我々はSolrのコレクションからのみproductIDsを取得できますか SolrCrudRepository検索の問題

public Interface ProductRepository extends SoleCrudrepository<productEntity, Integer){ 

    public List<Integer> getAllProductIDs(); 

} 

? 私は常に空の結果セットを返して

@Query("Select p.id from Product p) 

public List<Integer> findAllProductIDS(); 

てみました。

答えて

0

@Queryアノテーションでfieldsプロパティを使用できます。例えば:

@Query(fields = { "id" }) 
List findAllProductIds(); 

あなたは投影here

について読むことができます