robbr Posted September 22, 2009 Share Posted September 22, 2009 I have the applicationContext.xml on the classpath with the sessionFactory bean. I'm using annotations with Spring and Hibernate. Now when I test the connection I get a cryptic error: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: Address near line 1, column 27 [select address as address Address as address]The stack trace is absolutely no help, there is no "Caused By: " entry. Why is this statement even being executed? My Query text is blank. Even when I comment out all the mappings in my hibernate configuration file it tries to do this. Thanks in advance I'm really stumped on this one. Link to comment Share on other sites More sharing options...
sedat Posted January 2, 2010 Share Posted January 2, 2010 im same situation. i have exactly same error...does anyone help us Link to comment Share on other sites More sharing options...
kundan.scorpio Posted December 14, 2012 Share Posted December 14, 2012 I figured this out. You get this stupid error because of one sample query written in JRSpringLoadedHibernateConnection and developers of iReport forgot to include the mapping files. You get this error when you click on test button of spring loaded hibernate connection. You can ignore this error message. I have pasted the complete definition of this method. You can make out easily from the below method that it is trying to create a sessionfactory. once you obtain a sessionfactory, it is trying to execute this sample query for which no mapping file is defined.Even if you get this erros messgae click OK, save connection and proceed to use the connection. It works for me. I have verified this. public void test() throws Exception { try { Thread.currentThread().setContextClassLoader( IReportManager.getInstance().getReportClassLoader() ); SessionFactory sf = getSessionFactory(); if (sf == null) { JOptionPane.showMessageDialog(Misc.getMainWindow(), //I18n.getString("messages.connectionDialog.noSessionFactoryReturned", "No session factory returned. Check your session factory bean id against the spring configuration.", "Error",JOptionPane.ERROR_MESSAGE); } else { Session hb_session = sf.openSession(); Transaction transaction = hb_session.beginTransaction(); Query q = hb_session.createQuery("select "); q.setFetchSize(1); java.util.Iterator iterator = q.iterate(); // this is a stupid thing: iterator.next(); String[] aliases = q.getReturnAliases(); Type[] types = q.getReturnTypes(); JOptionPane.showMessageDialog(Misc.getMainWindow(), //I18n.getString("messages.connectionDialog.hibernateConnectionTestSuccessful", "iReport successfully created a Hibernate session factory from your Spring configuration.", "",JOptionPane.INFORMATION_MESSAGE); } } catch (Exception e) { e.printStackTrace(); JOptionPane.showMessageDialog(Misc.getMainWindow(),e.getMessage(), "Error",JOptionPane.ERROR_MESSAGE); } } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now