Count doesnt work on native query

I have the following code
String testQuery = “select * from ACT_HI_TASKINST”;
historyService.createNativeHistoricTaskInstanceQuery().sql(testQuery).count();//THis line is throwing an exception

Cause: org.apache.ibatis.executor.result.ResultMapException: Error attempting to get column ‘ID_’ from result set. Cause: An error occurred while converting the nvarchar value to JDBC data type BIGINT.

I can call the list, list page function , but calling count doesn’t work.
Using Microsoft SQL server.

the problem is:

historyService.createNativeHistoricTaskInstanceQuery().sql("SELECT count(*) FROM " + managementService.getTableName(HistoricTaskInstance.class)).count()