我有一个带有本机查询的Spring Data存储库方法
@Query(value = "SELECT g.*, gm.* FROM group g LEFT JOIN group_members gm ON g.group_id = gm.group_id and gm.user_id = :userId WHERE g.group_id = :groupId", nativeQuery = true)
GroupDetails getGroupDetails(@Param("userId") Integer userId, @Param("groupId") Integer groupId);
Run Code Online (Sandbox Code Playgroud)
我想将结果映射到非实体POJO GroupDetails.
是否有可能,如果可以的话,请你提供一个例子吗?
我将我的应用程序从 spring boot 2.2.5 升级到 2.3.3,并且我正在使用带有 5.4.20.Final 板载的 spring data JPA starter。我的实体在编译时得到增强。
现在,当我在覆盖方法上使用@EntityGraph带有attributePaths属性的注释时,我收到此警告:findAllJpaRepository
2020-08-19 12:13:41.121 WARN 9348 --- [nio-8060-exec-3] [] [] o.h.engine.internal.TwoPhaseLoad : Entity graph specified is not applicable to the entity [DictionaryLang(id=1601, name=null, lang=null)]. Ignored.
2020-08-19 12:13:41.483 WARN 9348 --- [nio-8060-exec-3] [] [] o.h.engine.internal.TwoPhaseLoad : Entity graph specified is not applicable to the entity [DictionaryValueLang(id=3051, lang=null, name=null)]. Ignored.
Run Code Online (Sandbox Code Playgroud)
即使此警告 - 图形已正确获取 - 我只能在日志中看到一个 SQL 查询,并且应用程序的行为与更新前一样。
这是我的存储库代码:
public interface DictionaryRepository extends JpaRepository<Dictionary, Long>, QuerydslPredicateExecutor<Dictionary> …Run Code Online (Sandbox Code Playgroud)