MSSQL | JDBI 3 | NoRowsSelect For Count Query After Update

184 views Asked by At

Java class creates a prepared statement and binds value MS-SQL is the data store used

Jars Used

  • jdbi3-core-3.8.2
  • HikariCP: 3.4.1
  • mssql-jdbc:7.2.2.jre8
DECLARE @status VARCHAR(max)
DECLARE @destination VARCHAR(max) = 'xyz'
DECLARE @attributes_var NVARCHAR(max)
-- status , current_destination , container_id
UPDATE dbo.container_master
SET @status= status, status = 'DELETED', @destination= current_destination , current_destination = null , @attributes_var = JSON_QUERY(attributes , '$')
WHERE container_id = 'cont_id'
--   current_destination ,
SELECT count(container_id) AS count
FROM dbo.container_master
     CROSS APPLY OPENJSON (attributes ) WITH (value NVARCHAR(100) '$')
where current_destination = @destination
and status <> 'DELETED'
AND attributes = JSON_QUERY(@attributes_var, '$')

Count Query when executed Returns No Rows , ResultSet is null Throwing a Non-TransientExecption

Query statement = handle.createQuery(query);
this.bindParameters(statement, queryParameters);
ResultBearing queryResults = (ResultBearing)statement.execute(ResultProducers.returningResults());
results = (List)queryResults.map(this.mapMapper).stream().map(this::toBytes).collect(Collectors.toList());

Last Line Throws a NonTransient Exception

Options Tried When Only a simple select queries are executed it works

Things Working Update Fired. Query executed successfully

Issue Handling of ResultSets

0

There are 0 answers