在Spring数据JPA中外部化本机查询 [英] Externalize native query in Spring data JPA

查看:106
本文介绍了在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.

推荐答案

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中外部化本机查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆