I don’t think you need to call addScalar here, the return type of the native query is already defined as Integer with the second parameter to the createNativeQuery method.