Using Hello World example created simple NewMessage class that is annotated. I did this to leave in mapped Message class in HelloWorld application. I am also using newest jars 3.2.0CR2 for annotations,entitymanager, tools is 3.2.0beta 7. Core is newest release. When query line :
List messages = newEm
.createQuery("from NewMessage m order by m.text asc")
.getResultList();
is ran the following exception is returned.
14:30:07,845 DEBUG QueryPlanCache:70 - unable to locate HQL query plan in cache; generating (from NewMessage m order by m.text asc)
14:30:08,436 DEBUG QueryTranslatorImpl:246 - parse() - HQL: from hello.NewMessage m order by m.text asc
14:30:08,486 DEBUG AST:266 - --- HQL AST ---
\-[QUERY] 'query'
+-[SELECT_FROM] 'SELECT_FROM'
| \-[FROM] 'from'
| \-[RANGE] 'RANGE'
| +-[DOT] '.'
| | +-[IDENT] 'hello'
| | \-[IDENT] 'NewMessage'
| \-[ALIAS] 'm'
\-[ORDER] 'order'
+-[DOT] '.'
| +-[IDENT] 'm'
| \-[IDENT] 'text'
\-[ASCENDING] 'asc'
14:30:08,486 DEBUG ErrorCounter:68 - throwQueryException() : no errors
14:30:08,756 DEBUG HqlSqlBaseWalker:111 - select << begin [level=1, statement=select]
14:30:08,846 DEBUG FromElement:105 - FromClause{level=1} : hello.NewMessage (m) -> newmessage0_
14:30:08,846 DEBUG FromReferenceNode:51 - Resolved : m -> newmessage0_.MESSAGE_ID
14:30:08,856 DEBUG DotNode:541 - getDataType() : text -> org.hibernate.type.StringType@eb7331
14:30:08,856 DEBUG FromReferenceNode:51 - Resolved : m.text -> newmessage0_.MESSAGE_TEXT
14:30:08,856 DEBUG HqlSqlBaseWalker:117 - select : finishing up [level=1, statement=select]
14:30:08,866 DEBUG HqlSqlWalker:516 - processQuery() : ( SELECT ( FromClause{level=1} NEW_MESSAGE newmessage0_ ) ( order ( newmessage0_.MESSAGE_TEXT newmessage0_.MESSAGE_ID text ) asc ) )
Exception in thread "main" java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: JPA-QL compliance requires select clause [from hello.NewMessage m order by m.text asc]
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:628)
at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:95)
at hello.HelloWorld.main(HelloWorld.java:74)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
Caused by: org.hibernate.hql.ast.QuerySyntaxException: JPA-QL compliance requires select clause [from hello.NewMessage m order by m.text asc]
at org.hibernate.hql.ast.tree.SelectClause.initializeDerivedSelectClause(SelectClause.java:261)
at org.hibernate.hql.ast.HqlSqlWalker.createSelectClauseFromFromClause(HqlSqlWalker.java:721)
at org.hibernate.hql.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:531)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:645)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:228)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:92)
I am a little stumped. Any quick thoughts?
|