I am using hibernate JPA to execute an stored procedure in spring application but it is resulting in below error. StoredPrcoedure does not have any parameters so below error is not intuitive. Any google search around this resulted in no results and references to spring/hibernate documentation also did not help. Any help around this would be greatly appreciated. I cannot seem to understand what I am doing wrong and totally stuck at this point..
Error:
org.hibernate.procedure.NoSuchParameterException: Could not locate parameter registered using that position [1]
at org.hibernate.procedure.internal.ProcedureCallImpl.getParameterRegistration(ProcedureCallImpl.java:338)
at org.hibernate.procedure.internal.ProcedureOutputsImpl.getOutputParameterValue(ProcedureOutputsImpl.java:68)
at org.hibernate.jpa.internal.StoredProcedureQueryImpl.getOutputParameterValue(StoredProcedureQueryImpl.java:276)
Entity class as below:
Code:
@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;
:
:
}
Stored procedure in MS SQL Server, existing one which I cannot modify.
Code:
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