HHH-4150 - Fix and test

Conflicts:
	hibernate-core/src/main/antlr/hql.g
HHH-7608 - Fix and test