java.lang.Integer cannot be cast to java.lang.Long

SQL query "select count(*) from SOME_TABLE" from Mondrian results in
Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long.

This code amendment attempt to avoid direct casts where the underlying type has been misinterpreted.