在Spring数据JPA中外部化本机查询

编程入门 行业动态 更新时间:2024-10-28 16:22:14
本文介绍了在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中外部化本机查询

本文发布于:2023-10-25 00:26:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1525416.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:本机   数据   Spring   JPA

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!