[hibernate-issues] [Hibernate-JIRA] Commented: (ANN-714) @NamedQuery always gives an Exception "unexpected token" no matter what query is used

VPC (JIRA) noreply at atlassian.com
Mon Mar 24 14:49:33 EDT 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/ANN-714?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_29858 ] 

VPC commented on ANN-714:
-------------------------

When @NamedNativeQuery is used, the following exception results:
Pure native scalar queries are not yet supported
org.hibernate.cfg.NotYetImplementedException: Pure native scalar queries are not yet supported
	at org.hibernate.cfg.annotations.QueryBinder.bindNativeQuery(QueryBinder.java:118)
	at org.hibernate.cfg.annotations.QueryBinder.bindNativeQueries(QueryBinder.java:197)
	at org.hibernate.cfg.AnnotationBinder.bindQueries(AnnotationBinder.java:307)
	at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:437)
	at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:534)
	at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:286)
	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
	at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)

And even when correct HQL select clause is used, it still says Errors in named queries. 

If Chris could run this with proper HQL select clause or NamedNativeQuery, can you please post your code? Because, although the bug is rejected, it still exists and I am pretty sure, I am doing it right. However, I would be more than happy to learn if I am doing it wrong.

Thanks,
VPC

> @NamedQuery always gives an Exception "unexpected token" no matter what query is used
> -------------------------------------------------------------------------------------
>
>                 Key: ANN-714
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-714
>             Project: Hibernate Annotations
>          Issue Type: Bug
>    Affects Versions: 3.3.1.GA
>         Environment: Windows XPP SP2, Weblogic Server wlserver_10.0, jdk150_11, Weblogic Workshop
>            Reporter: VPC
>
> @Entity 
> @Table(name="CONTACT") 
> @NamedQueries({ @NamedQuery(name = "selectall", query = "SELECT * FROM CONTACT") }) 
> public class Contact { 
> ---usual setter getters----
> }
> @NamedQuery annotation always throws the following exception at the following line: SessionFactory sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory(); 
> The stack trace of the exception is as follows:
> <Fri Mar 21 15:14:22 EDT 2008> <Info> <org.hibernate.tool.hbm2ddl.TableMetadata> <BEA-000000> <table found: hibernatetutorial.contact> 
> <Fri Mar 21 15:14:22 EDT 2008> <Info> <org.hibernate.tool.hbm2ddl.TableMetadata> <BEA-000000> <columns: [lastname, firstname, email, id]> 
> <Fri Mar 21 15:14:22 EDT 2008> <Info> <org.hibernate.tool.hbm2ddl.TableMetadata> <BEA-000000> <foreign keys: []> 
> <Fri Mar 21 15:14:22 EDT 2008> <Info> <org.hibernate.tool.hbm2ddl.TableMetadata> <BEA-000000> <indexes: []> 
> <Fri Mar 21 15:14:22 EDT 2008> <Info> <org.hibernate.tool.hbm2ddl.SchemaUpdate> <BEA-000000> <schema update complete> 
> <Fri Mar 21 15:14:22 EDT 2008> <Trace> <org.hibernate.connection.DriverManagerConnectionProvider> <BEA-000000> <returning connection to pool, pool size: 1> 
> <Fri Mar 21 15:14:22 EDT 2008> <Debug> <org.hibernate.impl.SessionFactoryImpl> <BEA-000000> <Checking 1 named HQL queries> 
> <Fri Mar 21 15:14:22 EDT 2008> <Debug> <org.hibernate.impl.SessionFactoryImpl> <BEA-000000> <Checking named query: selectall> 
> <Fri Mar 21 15:14:22 EDT 2008> <Trace> <org.hibernate.engine.query.QueryPlanCache> <BEA-000000> <unable to locate HQL query plan in cache; generating (SELECT * FROM CONTACT)> 
> <Fri Mar 21 15:14:22 EDT 2008> <Debug> <org.hibernate.hql.ast.QueryTranslatorImpl> <BEA-000000> <parse() - HQL: SELECT * FROM CONTACT> 
> <Fri Mar 21 15:14:22 EDT 2008> <Error> <org.hibernate.hql.PARSER> <BEA-000000> <line 1:8: unexpected token: *> 
> <Fri Mar 21 15:14:22 EDT 2008> <Debug> <org.hibernate.hql.ast.ErrorCounter> <BEA-000000> <line 1:8: unexpected token: *> 
> org.hibernate.HibernateException: Errors in named queries: selectall
> 	at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:365)
> 	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300)
> 	at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)
> 	at hib.FirstExample.main(FirstExample.java:18)
> <Fri Mar 21 15:14:22 EDT 2008> <Debug> <org.hibernate.hql.ast.AST> <BEA-000000> <--- HQL AST ---
>  \-[QUERY] 'query'
>     \-[SELECT_FROM] 'SELECT_FROM'
>        \-[FROM] 'FROM'
>           \-[RANGE] 'RANGE'
>              \-[IDENT] 'CONTACT'
> > 
> <Fri Mar 21 15:14:22 EDT 2008> <Debug> <org.hibernate.impl.SessionFactoryImpl> <BEA-000000> <Checking 0 named SQL queries> 
> <Fri Mar 21 15:14:22 EDT 2008> <Error> <org.hibernate.impl.SessionFactoryImpl> <BEA-000000> <Error in named query: selectall> 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list