I have a stored procedure in SQL Server 2017 that returns data as JSON in an nvarchar(max) output parameter.
I have checked to make sure the entire result set is being returned from the stored procedure by running it on the database and everything works there. It returns a JSON string well over 4000 characters.
However, in my spring boot api, using Hibernate 5.3.7, the output is truncated to 4000 characters.
Any ideas on how I can fix this please?
Code where I call the Stored Procedure:
StoredProcedureQuery query = entityManager
.createStoredProcedureQuery("usp_my_stored_proc");
query.registerStoredProcedureParameter("reportOutputData", String.class, ParameterMode.OUT);
query.execute();
return String.valueOf(query.getOutputParameterValue("reportOutputData"));
The query.getOutputParameterValue("reportOutputData")
has a length of 4000. It should be a lot longer (like 40,000+).
application.properties:
spring.jpa.properties.hibernate.dialect=com.company.package.config.CustomSQLServerDialect
CustomSQLServerDialect:
public class CustomSQLServerDialect extends SQLServer2012Dialect {
public CustomSQLServerDialect() {
super();
registerColumnType(Types.VARCHAR, "nvarchar(max)");
registerColumnType(Types.CLOB, "nvarchar(max)");
registerColumnType(Types.NVARCHAR, "nvarchar(max)");
registerColumnType(Types.NCLOB, "nvarchar(max)");
registerHibernateType(Types.NVARCHAR,
StandardBasicTypes.STRING.getName());
}
}