小编Has*_*Bit的帖子

在我的情况下,谁能告诉我弹簧数据投影的真正原因?

情况是:我有一个存储库和两种方法,其中一种看起来像:

//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)

我进行了更改以使用投影界面。简单的投影界面是: …

java hql h2 spring-data spring-boot

2
推荐指数
2
解决办法
2564
查看次数

标签 统计

h2 ×1

hql ×1

java ×1

spring-boot ×1

spring-data ×1