Jump to content
Changes to the Jaspersoft community edition download ×

Hibernate runtime query syntax exceptions


Recommended Posts

By: tortois - tortois

Hibernate runtime query syntax exceptions

2006-06-30 02:19

I have a simple report - one field in detail section.

SQL syntax for query is: SELECT street FROM address

 

Data source is provided via JRHibernateQueryExecuterFactory.PARAMETER_HIBERNATE_SESSION parameter.

 

Problem is that at runtime I get exceptions...

 

Many syntaxes tried.

 

example 1:

from Address

gives:

Caused by: java.lang.UnsupportedOperationException: select clause aliases are not supported by classic parser

at org.hibernate.hql.classic.QueryTranslatorImpl.getReturnAliases(QueryTranslatorImpl.java:230)

at org.hibernate.impl.SessionFactoryImpl.getReturnAliases(SessionFactoryImpl.java:669)

at org.hibernate.impl.AbstractQueryImpl.getReturnAliases(AbstractQueryImpl.java:487)

at net.sf.jasperreports.engine.query.JRHibernateQueryExecuter.getReturnAliases(JRHibernateQueryExecuter.java:349)

 

example 2:

select street from Address

gives:

Caused by: org.hibernate.QueryException: undefined alias: street [select street from com.company.addressbook.Address]

at org.hibernate.hql.classic.PathExpressionParser.token(PathExpressionParser.java:130)

at org.hibernate.hql.classic.ParserHelper.parse(ParserHelper.java:28)

at org.hibernate.hql.classic.SelectParser.token(SelectParser.java:176)

at org.hibernate.hql.classic.ClauseParser.token(ClauseParser.java:86)

at org.hibernate.hql.classic.ClauseParser.end(ClauseParser.java:113)

at org.hibernate.hql.classic.PreprocessingParser.end(PreprocessingParser.java:122)

at org.hibernate.hql.classic.ParserHelper.parse(ParserHelper.java:29)

at org.hibernate.hql.classic.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:176)

at org.hibernate.hql.classic.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:152)

at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:427)

at org.hibernate.impl.SessionFactoryImpl.getRepresentativeQuery(SessionFactoryImpl.java:675)

at org.hibernate.impl.SessionFactoryImpl.getReturnTypes(SessionFactoryImpl.java:665)

at org.hibernate.impl.AbstractQueryImpl.getReturnTypes(AbstractQueryImpl.java:483)

at net.sf.jasperreports.engine.query.JRHibernateQueryExecuter.getReturnTypes(JRHibernateQueryExecuter.java:338)

at net.sf.jasperreports.engine.data.JRHibernateAbstractDataSource.assignReaders(JRHibernateAbstractDataSource.java:84)

 

example 3:

select ad.street from Address ad

gives:

Caused by: java.lang.UnsupportedOperationException: select clause aliases are not supported by classic parser

at org.hibernate.hql.classic.QueryTranslatorImpl.getReturnAliases(QueryTranslatorImpl.java:230)

at org.hibernate.impl.SessionFactoryImpl.getReturnAliases(SessionFactoryImpl.java:669)

at org.hibernate.impl.AbstractQueryImpl.getReturnAliases(AbstractQueryImpl.java:487)

at net.sf.jasperreports.engine.query.JRHibernateQueryExecuter.getReturnAliases(JRHibernateQueryExecuter.java:349)

at net.sf.jasperreports.engine.data.JRHibernateAbstractDataSource.assignReaders(JRHibernateAbstractDataSource.java:85)

 

Any ideas how to overcome this problem?

 

 

By: Lucian Chirita - lucianc

RE: Hibernate runtime query syntax exceptions

2006-06-30 03:12

The current JR Hibernate query executer doesn't work with the classical (Hibernate 2.1) query parser as it uses the query reflection capabilities to determine the report field mapping.

 

If you have to use the classical parser, you need a different Hibernate data source implementation that uses another mechanism to map report fields to query result values.

 

HTH,

Lucian

 

 

By: tortois - tortois

RE: Hibernate runtime query syntax exceptions

2006-06-30 03:58

Changing hibernate.query.factory_class property

from

org.hibernate.hql.classic.ClassicQueryTranslatorFactory

to org.hibernate.hql.ast.ASTQueryTranslatorFactory

helped.

 

got to check if other parts of app are still working though...

 

Thanks.

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...