Fixed the nasty hibernate HQL to SQL translation problem causing incorrect query result in MySQL.