本文介绍了在Spring数据JPA中外部化本机查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用spring-data JpaRepository. 我有以下本地查询:
I am using spring-data JpaRepository. I have the following native query :
@Query(value = "SELECT SUBSTRING_INDEX(u.email, '@', -1) as domain, COUNT(*) as domainCount, r.invite_organization_id" + " FROM srs_users as u,srs_user_registrations as r where u.user_id=r.user_id and r.invite_organization_id=:orgId" + " GROUP BY " + "SUBSTRING_INDEX(u.email, '@', -1) ORDER BY domainCount DESC", nativeQuery = true) List<Object[]> countTopDomain(@Param("orgId") String orgId );是否可以像其他命名查询一样,在jpa-named-queries.properties中将上述本机查询外部化.
Can we externalize the above native query in jpa-named-queries.properties just like other named queries.
推荐答案您可以使用JPA命名查询.但是,恐怕这并不是您想要的.除此之外,不支持外部化SQL语句.
You can use JPA Named queries. But I'm afraid that is not exactly what you are looking for. Other than that there is no support of externalizing SQL statements.
更多推荐
在Spring数据JPA中外部化本机查询
发布评论