情况是:我有一个存储库和两种方法,其中一种看起来像:
//There is no warning about: Activity domain type or valid projection interface expected here...
@Query("select distinct a.creatorId from Activity a")
Optional<List<String>> findAllCreatorIds();
Run Code Online (Sandbox Code Playgroud)
第二种方法如下所示:
//There i have warning about: Activity domain type or valid projection interface expected here
@Query("select distinct a.creatorId from Activity a join a.categories c where c.name in ?1")
Optional<List<String>> findAllCreatorIdsByCategoryNames(Set<String> categoryNames);
Run Code Online (Sandbox Code Playgroud)
看起来可行,并且通过了测试,并且生成的查询如下:
SELECT DISTINCT activity0_.created_by AS col_0_0_
FROM activities activity0_
INNER JOIN category_item categories1_ ON
activity0_.id=categories1_.activity_id
INNER JOIN categories category2_ ON
categories1_.category_id=category2_.id
WHERE category2_.name IN (?)
Run Code Online (Sandbox Code Playgroud)
我进行了更改以使用投影界面。简单的投影界面是: …