是否可以在 Spring Repository 中使用原始 SQL [英] Is it possible to use raw SQL within a Spring Repository
本文介绍了是否可以在 Spring Repository 中使用原始 SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在 Spring Data Repository 中使用原始 SQL,这可能吗?我在 @Query
周围看到的一切都是基于实体的.
I need to use raw SQL within a Spring Data Repository, is this possible? Everything I see around @Query
is always entity based.
推荐答案
@Query 注释允许通过将 nativeQuery 标志设置为 true 来执行本机查询.
The @Query annotation allows to execute native queries by setting the nativeQuery flag to true.
引用 Spring Data JPA 参考文档一>.
Quote from Spring Data JPA reference docs.
另外,参见 本节 关于如何使用命名的本机查询执行此操作.
Also, see this section on how to do it with a named native query.
这篇关于是否可以在 Spring Repository 中使用原始 SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文