使用 Spring 调用数据库函数 [英] Call database function with Spring

查看:38
本文介绍了使用 Spring 调用数据库函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要查询数据库的一个函数,通过SQL,很简单的事情

I need to query a function of the database, by SQL, something so simple as

@Query("SELECT random()")

如何实现一个域/存储库服务来实现它?

how to implement a domain/repository or service method that do it?

推荐答案

各种如何将存储过程与 Spring Data JPA 绑定(使用 JPA 2.1).

There are various ways how to bind stored procedures with Spring Data JPA (using JPA 2.1).

最简单的例子:

@Procedure("random")
Integer randomStoredProcedure();

这篇关于使用 Spring 调用数据库函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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