Query hibQuery = session.createQuery(query);
SessionFactory sessFact = session.getSessionFactory();
SessionFactoryImplementor imple = (SessionFactoryImplementor) sessFact;
ASTQueryTranslatorFactory factory = new ASTQueryTranslatorFactory();
QueryTranslator trans = null;
// Hibernate 3.0
Class[] parsTypes = null;
parsTypes = new Class[3];
parsTypes[0] = String.class;
parsTypes[1] = Map.class;
parsTypes[2] = SessionFactoryImplementor.class;
Method createQueryTranslatorMethod = null;
try{
createQueryTranslatorMethod = factory.getClass().getMethod("createQueryTranslator", parsTypes);
try{
trans = (QueryTranslator)createQueryTranslatorMethod.invoke(factory, new Object[]{hibQuery.getQueryString(), Collections.EMPTY_MAP, imple});
}catch (Throwable e) {
e.printStackTrace();
}
}catch (NoSuchMethodException e) {
parsTypes = new Class[4];
parsTypes[0] = String.class;
parsTypes[1] = String.class;
parsTypes[2] = Map.class;
parsTypes[3] = SessionFactoryImplementor.class;
try{
createQueryTranslatorMethod = factory.getClass().getMethod("createQueryTranslator", parsTypes);
if (createQueryTranslatorMethod != null){
try{
trans = (QueryTranslator)createQueryTranslatorMethod.invoke(factory, new Object[]{String.valueOf(System.currentTimeMillis()), hibQuery.getQueryString(),Collections.EMPTY_MAP, imple});
}catch (Throwable t) {