0 Replies Latest reply on Jul 16, 2008 12:35 PM by Kenneth René Sánchez Sánchez

    QuerySyntaxException class is not mapped

    Kenneth René Sánchez Sánchez Newbie

      Hi,

      I have a jar file (acad.jar) than contain TemaIcfes Entity:

      package co.academico.entidades;

      import java.io.Serializable;
      import javax.persistence.Entity;
      import javax.persistence.Id;
      import javax.persistence.Table;
      import javax.persistence.GeneratedValue;

      import org.jboss.seam.annotations.Name;

      @Entity
      @Name("TemaIcfes")
      @Table(name = "temas_icfes")
      public class TemaIcfes implements Serializable{

      @Id
      @GeneratedValue
      private short tema;
      private String descripcion_tema;

      public short getTema(){
      return tema;
      }

      public void setTema(short tema){
      this.tema = tema;
      }

      public String getDescripcion_tema(){
      return descripcion_tema;
      }

      public void setDescripcion_tema(String descripcion_tema){
      this.descripcion_tema = descripcion_tema;
      }
      }


      The problem is that when I use it in another application through an EJB shows the following error:

      Exception during request processing: Caused by javax.el.ELException with message: "javax.ejb.EJBTransactionRolledbackException: org.hibernate.hql.ast.QuerySyntaxException: TemaIcfes is not mapped [SELECT a FROM TemaIcfes a ORDER BY tema]"

      Classes:

      HacerMantenimiento.java:

      package co.academico.admin;

      import java.util.List;
      import co.academico.entidades.TemaIcfes;
      import javax.ejb.Local;

      @Local
      public interface HacerMantenimiento{

      public void crear(TemaIcfes tema);
      public List consultarTemaIcfes();
      public void modificar(TemaIcfes tema);
      public void listar();
      public void eliminar(TemaIcfes tema);

      public void destroy();
      }

      HacerMantenimientoEJB.java:

      package co.academico.admin;

      import static org.jboss.seam.ScopeType.SESSION;
      import java.util.List;
      import co.academico.entidades.TemaIcfes;
      import org.jboss.seam.annotations.Destroy;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Scope;
      import org.jboss.seam.annotations.datamodel.DataModel;
      import javax.ejb.Remove;
      import javax.ejb.Stateful;
      import javax.persistence.EntityManager;
      import javax.persistence.PersistenceContext;

      @Stateful
      @Scope(SESSION)
      @Name("hacerMantenimiento")
      public class HacerMantenimientoEJB implements HacerMantenimientoTemaIcfes{

      @PersistenceContext
      private EntityManager em;

      @DataModel
      private List temasIcfes;

      public void crear(TemaIcfes tema){
      em.persist(tema);
      }

      public List consultarTemaIcfes(){
      temasIcfes = em.createQuery
      ("SELECT a "+
      "FROM TemaIcfes a "+
      "ORDER BY tema").getResultList();
      return temasIcfes;
      }

      public void modificar(TemaIcfes tema){
      em.merge(tema);
      em.flush();
      }

      public void listar(){}

      public void eliminar(TemaIcfes tema){
      em.remove(tema);
      }

      @Remove @Destroy
      public void destroy(){}
      }


      home.xhtml:

      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
      xmlns:s="http://jboss.com/products/seam/taglib"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:rich="http://richfaces.org/rich"
      template="layout/template.xhtml">

      <ui:define name="body">

      <h:messages globalOnly="true" styleClass="message"/>

      <rich:panel>

      <h:outputText
      value="No existen temas registrados"
      rendered="#{temasIcfes != null and temasIcfes.rowCount==0}"/>

      <h:dataTable id="temasIcfes"
      value="#{temasIcfes}"
      var="tema"
      rendered="#{temasIcfes.rowCount>0}"
      style=" width : 377px;">

      <h:column>
      <f:facet name="header">Codigo</f:facet>
      #{tema.tema}
      </h:column>
      <h:column>
      <f:facet name="header">Descripcion</f:facet>
      #{tema.descripcion_tema}
      </h:column>
      </h:dataTable>

      </rich:panel>

      </ui:define>
      </ui:composition>

      pages.xml:

      ...
      <page view-id="/home.xhtml" action="#{hacerMantenimiento.consultarTemaIcfes}">


      <redirect view-id="/main.xhtml"/>


      ...

      What is the problem?
      They could help to solve this problem please?