HHH-8850 - fixed exception when calling addScalar on NamedSqlQuery

fixed exception and added testcase