使用@NamedStoredProcedureQuery 时如何指定架构名称 [英] How to specify Schema name while using @NamedStoredProcedureQuery
问题描述
我正在尝试使用 Spring Annotation @NamedStoredProcedureQuery 调用无参数存储过程.
I am trying to invoke a parameter less stored procedure using the Spring Annotation @NamedStoredProcedureQuery.
技术栈是 Spring Data JPA with Hibernate,数据库是 Teradata.
Technology stack is Spring Data JPA with Hibernate, and database is Teradata.
它总是无法说找不到过程",因为它试图调用
It always fails saying "Procedure not found" because it tries to invoke as
call proc_name()
肯定会失败.
然而调用存储过程的正确方法是
However the right way to call the stored procedure is
call schemaName.proc_name()
我想不出在我创建的实体中指定架构名称的方法.
I can't figure out a way to specify the schema name in the Entity that I have created.
@NamedStoredProcedureQuery(
name="proc_name",
procedureName="proc_name",
resultClasses = { Sc_Refresh.class }
)
@Entity
@Table(schema = "Schema_Name", name = "TEMP_TABLE" )
public class Sc_Refresh {
}
有人可以帮忙吗?
推荐答案
找到解决方案.
在 Repo 层中,我们使用 @Procedure 注释,我们应该提供过程的完全限定名称.示例,
In the Repo layer, wherein we are using @Procedure annotation, we should provide the fully qualified name for the procedure. Example,
@Repository
public interface Repo extends JpaRepository<Entity, Long>{
@Procedure("SCHEMA_NAME.PROC_NAME")
void explicitlyNamedProcName();
}
这篇关于使用@NamedStoredProcedureQuery 时如何指定架构名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!