public String hqlToHibernate5(String hql) { String[] tmp = hql.split(" "); String hqlTmp = ""; for (int i = 0, j = 0; i < tmp.length; i++) { String t = tmp[i].trim(); if (t.indexOf("?") > -1) { ++j; hqlTmp = hqlTmp.concat(" ?").concat(String.valueOf(j)).concat(" "); } else { hqlTmp = hqlTmp.concat(t).concat(" "); } } return hqlTmp; }