Fixing Rewriting of User Query to HQL

Removing trailing and leadspace in the column names so that HQL generated is a valid SQL.