Spring Repository中是否可以使用原始SQL? [英] Is it possible to use raw SQL within a Spring Repository

查看:102
本文介绍了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屋!

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