3 Replies Latest reply on Mar 7, 2006 2:26 AM by Martin Heinemann

    createQuery() failure

    Roberto Colmegna Newbie

      ABean:

      package test.ejb.entity;

      import java.util.*;
      import javax.persistence.*;
      import javax.ejb.*;

      @Entity
      @Remote
      @Table(name="a")

      @NamedQuery(
      name="ABean_findAll",
      query="SELECT o FROM ABean o ORDER BY o.m_sInfo DESC"
      )

      public class ABean extends IdEntityBean {
      @Column(name="info")
      String m_sInfo;

      @PrePersist
      public void setCreateInfo() {
      m_sInfo = "";
      }

      public String getInfo() { return m_sInfo;}
      public void setInfo(String info) { m_sInfo
      }



      client (Stateless) call:

      public ABean[] getAll() {
      return (ABean[])m_oEM.createQuery("ABean_findAll").
      getResultList().toArray(new ABean[0]);
      }




      Error:
      2006-03-03 16:35:02,192 DEBUG [org.hibernate.hql.ast.QueryTranslatorImpl] parse(
      ) - HQL: ABean_findAll
      2006-03-03 16:35:02,193 ERROR [org.hibernate.hql.PARSER] line 1:1: unexpected to
      ken: ABean_findAll
      2006-03-03 16:35:02,193 DEBUG [org.hibernate.hql.ast.ErrorCounter] line 1:1: unexpected token: ABean_findAll line 1:1: unexpected token: ABean_findAll at org.hibernate.hql.antlr.HqlBaseParser.statement(HqlBaseParser.java:171)


      Parsed statement:
      2006-03-03 16:34:53,999 DEBUG [org.hibernate.hql.ast.QueryTranslatorImpl] parse(
      ) - HQL: SELECT o FROM test.ejb.entity.ABean o ORDER BY o.m_sInfo DESC
      2006-03-03 16:34:54,001 DEBUG [org.hibernate.hql.ast.AST] --- HQL AST ---
      \-[QUERY] 'query'
      +-[SELECT_FROM] 'SELECT_FROM'
      | +-[FROM] 'FROM'
      | | \-[RANGE] 'RANGE'
      | | +-[DOT] '.'
      | | | +-[DOT] '.'
      | | | | +-[DOT] '.'
      | | | | | +-[IDENT] 'test'
      | | | | | \-[IDENT] 'ejb'
      | | | | \-[IDENT] 'entity'
      | | | \-[IDENT] 'ABean'
      | | \-[ALIAS] 'o'
      | \-[SELECT] 'SELECT'
      | \-[IDENT] 'o'
      \-[ORDER] 'ORDER'
      +-[DOT] '.'
      | +-[IDENT] 'o'
      | \-[IDENT] 'm_sInfo'
      \-[DESCENDING] 'DESC'



      TIA
      Roberto Colmegna