【发布时间】:2015-03-25 12:45:07
【问题描述】:
我正在使用休眠 JPA 在 Spring 应用程序中执行存储过程,但它导致以下错误。 StoredPrcoedure 没有任何参数,因此下面的错误并不直观。围绕此的任何谷歌搜索都没有结果,并且对 spring/hibernate 文档的引用也没有帮助。对此的任何帮助将不胜感激。我似乎无法理解我做错了什么并且完全停留在这一点上..
错误:
org.hibernate.procedure.NoSuchParameterException:找不到 使用该位置 [1] 注册的参数 org.hibernate.procedure.internal.ProcedureCallImpl.getParameterRegistration(ProcedureCallImpl.java:338) 在 org.hibernate.procedure.internal.ProcedureOutputsImpl.getOutputParameterValue(ProcedureOutputsImpl.java:68) 在 org.hibernate.jpa.internal.StoredProcedureQueryImpl.getOutputParameterValue(StoredProcedureQueryImpl.java:276)
实体类如下:
@Entity
@NamedStoredProcedureQuery(name = "getCountries", procedureName = "spLT_Countries", resultClasses = Country.class)
public class Country implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name = "countryid")
private Long id;
@Column(name = "ISOCountrycode")
private String iso2;
@Column(name="Country")
private String name;
:
:
}
MS SQL Server 中的存储过程,现有一个我无法修改。
ALTER procedure [dbo].[spLT_Countries]
as
begin
SET NOCOUNT ON
Set transaction isolation level read uncommitted
Select countryid, ISOCountrycode, Country from RN_Country order by Country
end
任何帮助将不胜感激,因为我无法取得进一步的进展。
【问题讨论】:
-
如何调用存储过程?
-
我正在使用 JPA 注释 - @NamedStoredProcedureQuery(name = "getCountries", procedureName = "spLT_Countries", resultClasses = Country.class) 调用过程但映射参数失败
-
@NamedStoredProcedureQuery只是声明查询。它不会调用它。
标签: hibernate spring-boot spring-data-jpa