Reputation: 21
After upgrading to Java 17 and hibernate 6, the sequence of IN parameter was changed. I was able to fix this by changing the sequence while sending the IN parameter to the procedure.
But I am migrating my project to java 8 to 17, and by this solution, there are lots of changes in my code. Please suggest some simple fix, I don't want to change in my java input seq as well in proc sequence. Is there any configuration that disallow the sequence and use named parameter property.
ClassEntity saveFactorResponse = (ResponseEntity) entityManager
.createStoredProcedureQuery("proc_res", "ClassEntity")
.registerStoredProcedureParameter("id", String.class, ParameterMode.IN)
.registerStoredProcedureParameter("name", String.class, ParameterMode.IN)
.registerStoredProcedureParameter("userName", String.class, ParameterMode.IN)
.registerStoredProcedureParameter("productType", String.class, ParameterMode.IN)
.setParameter("id", name) // Ensure this matches the procedure's parameter name
.setParameter("name", id)
.setParameter("userName", userName)
.setParameter("productType", productType)
.getSingleResult();
ALTER PROCEDURE [dbo].[proc_res]
@name nvarchar(100),
@id nvarchar(100),
@userName nvarchar(100),
@productType nvarchar(100)
AS
BEGIN
-- Your procedure logic goes here
END
Before migration were are using java 8 with springboot 2.x version. It's working fine, now I am using java 17 with springboot 3.x version, now it used java param sequence.. Like @name has stored userName value, @id store productType value, how to fix.
Upvotes: 2
Views: 213