2 Replies Latest reply on Nov 17, 2009 7:21 PM by prati bha

    Error :java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: asset is not mapped select a from asset a order by a.assetType

    prati bha Newbie
      Hi
      I have and entity which is
      import javax.persistence.Entity;
      @Entity
      @Name("asset")
      @Table(name = "asset")

      public class Asset implements Serializable {
              private static final long serialVersionUID = 1L;
              private int assetId;
              private String assetType;
              private String assetSubType;
              private String location;
             
              @Id @GeneratedValue(strategy=GenerationType.AUTO)
              public int getAssetId() {
                      return assetId;
      '
      '
      '}
      and in Action class i am writing
      public  List<Asset> queryAssets()
              {
              Query q = em.createQuery("select a from asset a order by a.assetType");
              System.out.println("q.getSingleResult()"+q.getSingleResult());
             
              assetList = em.createQuery("select a from asset a order by a.assetType").getResultList();
             
                  //return assetList;
              return q.getResultList();
              }

      I am getting this error when i try to run the application
      Caused by: javax.ejb.EJBException: java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: asset is not mapped [select a from asset a order by a.assetType]
              at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:77)
              at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
              at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:190)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
              at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
              at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
              at org.jboss.ejb3.security.RoleBasedAuthorizationInterceptorv2.invoke(RoleBasedAuthorizationInterceptorv2.java:201)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
              at org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:186)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
              at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:41)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
              at org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:67)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

      Please Help