6 Replies Latest reply on Mar 25, 2010 11:40 AM by ZHIGUO LI

    Persistent Class or ResultList problem

    Pete Spelman Newbie
      Still trying!

      Using:
      Seam 2.1.1
      JBoss 5.0.1
      Ant 1.7
      MSSQLServer2005

      Have managed to sort out my original db connection problem which was the connection string.
      Have run seam setup, seam create-project, seam generate and seam explode.
      When I get my server running, I have a nice default web interface which lists the one table I have configured it to use. when I click the link I get a List page with no data (in the first instance) or a ResultList error (in the second instance)

      In EmployList.java if I use the following:

      private static final String EJBQL = "select employees from org.jboss.northwind3.Employees employees";
      Then I get the following message:
      ...
      ...
      10:39:22,086 INFO  [compiler] Added Library from: vfszip:/C:/jboss501/server/def
      ault/deploy/Northwind3.war/WEB-INF/lib/richfaces-ui.jar/META-INF/richfaces.tagli
      b.xml
      10:39:22,086 INFO  [compiler] Added Library from: vfszip:/C:/jboss501/server/def
      ault/deploy/Northwind3.war/WEB-INF/lib/jboss-seam-rss.jar/META-INF/seam-rss.tagl
      ib.xml
      10:39:22,101 INFO  [compiler] Added Library from: vfszip:/C:/jboss501/server/def
      ault/deploy/Northwind3.war/WEB-INF/lib/jboss-seam-excel.jar/META-INF/seam-excel.
      taglib.xml
      10:39:22,117 INFO  [compiler] Added Library from: vfszip:/C:/jboss501/server/def
      ault/deploy/Northwind3.war/WEB-INF/lib/jboss-seam-ui.jar/META-INF/s.taglib.xml
      10:39:30,992 WARN  [QuerySplitter] no persistent classes found for query class:
      select employees from org.jboss.northwind3.Employees employees

      Whereas if I use this:
      private static final String EJBQL = "select employees from Employees employees";
      I get the this message:
      ...
      ...
      10:44:46,211 INFO  [compiler] Added Library from: vfszip:/C:/jboss501/server/def
      ault/deploy/Northwind3.war/WEB-INF/lib/jboss-seam-excel.jar/META-INF/seam-excel.
      taglib.xml
      10:44:46,226 INFO  [compiler] Added Library from: vfszip:/C:/jboss501/server/def
      ault/deploy/Northwind3.war/WEB-INF/lib/jboss-seam-ui.jar/META-INF/s.taglib.xml
      10:45:01,211 ERROR [viewhandler] Error Rendering View[/EmployeesList.xhtml]
      javax.faces.FacesException: javax.el.ELException: /EmployeesList.xhtml @32,62 re
      ndered="#{empty employeesList.resultList}": Error reading 'resultList' on type c
      om.pete.northwind3.EmployeesList_$$_javassist_1
              at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java
      :393)
              at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:276
      )
              at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:
      262)
              at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRend
      erer.java:220)
      ...
      ... 58 more
      Caused by: java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntax
      Exception: Employees is not mapped [select employees from Employees employees]
              at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException
      (AbstractEntityManagerImpl.java:601)
              at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntit
      yManagerImpl.java:96)
              at org.jboss.seam.persistence.EntityManagerProxy.createQuery(EntityManag
      erProxy.java:81)
      ...
      ... 59 more
      Caused by: org.hibernate.hql.ast.QuerySyntaxException: Employees is not mapped [
      select employees from Employees employees]
              at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister
      (SessionFactoryHelper.java:181)
              at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElem
      entFactory.java:110)


      In the first instance the class gets mapped, in the second it does not.

      Any further help appreciated.
      Pete
        • 1. Re: Persistent Class or ResultList problem
          Pete Spelman Newbie

          Can anybody point me at where I should be looking to resolve this?


          Its frustrating because I have the early stages of the 'Seam in Action' example and another simple personal project running on my laptop (albeit on Ubuntu).


          Thanks
          Pete

          • 2. Re: Persistent Class or ResultList problem
            Stuart Douglas Master

            Can you post your Employees entitiy?

            • 3. Re: Persistent Class or ResultList problem
              Pete Spelman Newbie
              package org.jboss.northwind3;
              // Generated 18-Aug-2009 11:43:02 by Hibernate Tools 3.2.2.GA

              import java.io.Serializable;
              import java.util.Date;
              import java.util.HashSet;
              import java.util.Set;
              import javax.persistence.CascadeType;
              import javax.persistence.Column;
              import javax.persistence.Entity;
              import javax.persistence.FetchType;
              import javax.persistence.Id;
              import javax.persistence.JoinColumn;
              import javax.persistence.ManyToOne;
              import javax.persistence.OneToMany;
              import javax.persistence.Table;
              import javax.persistence.Temporal;
              import javax.persistence.TemporalType;
              import org.hibernate.validator.NotNull;

              /**
              * Employees generated by hbm2java
              */
              @Entity
              @Table(name = "Employees", schema = "dbo")
              public class Employees implements java.io.Serializable {

                      private int employeeId;
                      private Employees employees;
                      private Serializable lastName;
                      private Serializable firstName;
                      private Serializable title;
                      private Serializable titleOfCourtesy;
                      private Date birthDate;
                      private Date hireDate;
                      private Serializable address;
                      private Serializable city;
                      private Serializable region;
                      private Serializable postalCode;
                      private Serializable country;
                      private Serializable homePhone;
                      private Serializable extension;
                      private byte[] photo;
                      private Serializable notes;
                      private Serializable photoPath;
                      private Set<Employees> employeeses = new HashSet<Employees>(0);
                      private Set<Employees> employeeses_1 = new HashSet<Employees>(0);
                      private Set<Employees> employeeses_2 = new HashSet<Employees>(0);

                      public Employees() {
                      }

                      public Employees(int employeeId, Serializable lastName,
                                      Serializable firstName) {
                              this.employeeId = employeeId;
                              this.lastName = lastName;
                              this.firstName = firstName;
                      }
                      public Employees(int employeeId, Employees employees,
                                      Serializable lastName, Serializable firstName, Serializable title,
                                      Serializable titleOfCourtesy, Date birthDate, Date hireDate,
                                      Serializable address, Serializable city, Serializable region,
                                      Serializable postalCode, Serializable country,
                                      Serializable homePhone, Serializable extension, byte[] photo,
                                      Serializable notes, Serializable photoPath,
                                      Set<Employees> employeeses, Set<Employees> employeeses_1,
                                      Set<Employees> employeeses_2) {
                              this.employeeId = employeeId;
                              this.employees = employees;
                              this.lastName = lastName;
                              this.firstName = firstName;
                              this.title = title;
                              this.titleOfCourtesy = titleOfCourtesy;
                              this.birthDate = birthDate;
                              this.hireDate = hireDate;
                              this.address = address;
                              this.city = city;
                              this.region = region;
                              this.postalCode = postalCode;
                              this.country = country;
                              this.homePhone = homePhone;
                              this.extension = extension;
                              this.photo = photo;
                              this.notes = notes;
                              this.photoPath = photoPath;
                              this.employeeses = employeeses;
                              this.employeeses_1 = employeeses_1;
                              this.employeeses_2 = employeeses_2;
                      }

                      @Id
                      @Column(name = "EmployeeID", unique = true, nullable = false)
                      @NotNull
                      public int getEmployeeId() {
                              return this.employeeId;
                      }

                      public void setEmployeeId(int employeeId) {
                              this.employeeId = employeeId;
                      }
                      @ManyToOne(fetch = FetchType.LAZY)
                      @JoinColumn(name = "ReportsTo")
                      public Employees getEmployees() {
                              return this.employees;
                      }

                      public void setEmployees(Employees employees) {
                              this.employees = employees;
                      }

                      @Column(name = "LastName", nullable = false)
                      @NotNull
                      public Serializable getLastName() {
                              return this.lastName;
                      }

                      public void setLastName(Serializable lastName) {
                              this.lastName = lastName;
                      }

                      @Column(name = "FirstName", nullable = false)
                      @NotNull
                      public Serializable getFirstName() {
                              return this.firstName;
                      }

                      public void setFirstName(Serializable firstName) {
                              this.firstName = firstName;
                      }

                      @Column(name = "Title")
                      public Serializable getTitle() {
                              return this.title;
                      }

                      public void setTitle(Serializable title) {
                              this.title = title;
                      }

                      @Column(name = "TitleOfCourtesy")
                      public Serializable getTitleOfCourtesy() {
                              return this.titleOfCourtesy;
                      }

                      public void setTitleOfCourtesy(Serializable titleOfCourtesy) {
                              this.titleOfCourtesy = titleOfCourtesy;
                      }
                      @Temporal(TemporalType.TIMESTAMP)
                      @Column(name = "BirthDate", length = 23)
                      public Date getBirthDate() {
                              return this.birthDate;
                      }

                      public void setBirthDate(Date birthDate) {
                              this.birthDate = birthDate;
                      }
                      @Temporal(TemporalType.TIMESTAMP)
                      @Column(name = "HireDate", length = 23)
                      public Date getHireDate() {
                              return this.hireDate;
                      }

                      public void setHireDate(Date hireDate) {
                              this.hireDate = hireDate;
                      }

                      @Column(name = "Address")
                      public Serializable getAddress() {
                              return this.address;
                      }

                      public void setAddress(Serializable address) {
                              this.address = address;
                      }

                      @Column(name = "City")
                      public Serializable getCity() {
                              return this.city;
                      }

                      public void setCity(Serializable city) {
                              this.city = city;
                      }

                      @Column(name = "Region")
                      public Serializable getRegion() {
                              return this.region;
                      }

                      public void setRegion(Serializable region) {
                              this.region = region;
                      }

                      @Column(name = "PostalCode")
                      public Serializable getPostalCode() {
                              return this.postalCode;
                      }

                      public void setPostalCode(Serializable postalCode) {
                              this.postalCode = postalCode;
                      }

                      @Column(name = "Country")
                      public Serializable getCountry() {
                              return this.country;
                      }

                      public void setCountry(Serializable country) {
                              this.country = country;
                      }

                      @Column(name = "HomePhone")
                      public Serializable getHomePhone() {
                              return this.homePhone;
                      }

                      public void setHomePhone(Serializable homePhone) {
                              this.homePhone = homePhone;
                      }

                      @Column(name = "Extension")
                      public Serializable getExtension() {
                              return this.extension;
                      }

                      public void setExtension(Serializable extension) {
                              this.extension = extension;
                      }

                      @Column(name = "Photo")
                      public byte[] getPhoto() {
                              return this.photo;
                      }

                      public void setPhoto(byte[] photo) {
                              this.photo = photo;
                      }

                      @Column(name = "Notes")
                      public Serializable getNotes() {
                              return this.notes;
                      }

                      public void setNotes(Serializable notes) {
                              this.notes = notes;
                      }

                      @Column(name = "PhotoPath")
                      public Serializable getPhotoPath() {
                              return this.photoPath;
                      }

                      public void setPhotoPath(Serializable photoPath) {
                              this.photoPath = photoPath;
                      }
                      @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "employees")
                      public Set<Employees> getEmployeeses() {
                              return this.employeeses;
                      }

                      public void setEmployeeses(Set<Employees> employeeses) {
                              this.employeeses = employeeses;
                      }
                      @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "employees")
                      public Set<Employees> getEmployeeses_1() {
                              return this.employeeses_1;
                      }

                      public void setEmployeeses_1(Set<Employees> employeeses_1) {
                              this.employeeses_1 = employeeses_1;
                      }
                      @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "employees")
                      public Set<Employees> getEmployeeses_2() {
                              return this.employeeses_2;
                      }

                      public void setEmployeeses_2(Set<Employees> employeeses_2) {
                              this.employeeses_2 = employeeses_2;
                      }

              }
              • 4. Re: Persistent Class or ResultList problem
                Stuart Douglas Master

                Are you sure you entity is being detected properly by hibernate? Do you see lines like the following on server startup:


                14:13:39,468 INFO  [AnnotationBinder] Binding entity from annotated class: org.jboss.northwind3.Employees
                14:13:39,469 INFO  [EntityBinder] Bind entity org.jboss.northwind3.Employees on table Employees
                



                I don't think hibernate will complaining about a class not being mapped when the reference is fully qualified, because it lets you do things like:


                 select o from java.lang.Object o
                



                or


                select e from com.mypackege.MyInterface e
                


                • 5. Re: Persistent Class or ResultList problem
                  Pete Spelman Newbie
                  Yep, the binding and mapping appears in the JBoss output.
                  Also, the project was generated with the file hibernate-console.properties and but I now notice that 'hibernate.properties could not be found'. Where is that file supposed to be found?

                  Extract from JBoss output:
                  ...
                  ...
                  09:17:10,860 INFO  [PersistenceUnitDeployment] Starting persistence unit persist
                  ence.unit:unitName=#Northwind3
                  09:17:11,125 INFO  [Version] Hibernate Annotations 3.4.0.GA
                  09:17:11,172 INFO  [Environment] Hibernate 3.3.1.GA
                  09:17:11,203 INFO  [Environment] hibernate.properties not found
                  09:17:11,219 INFO  [Environment] Bytecode provider name : javassist
                  09:17:11,250 INFO  [Environment] using JDK 1.4 java.sql.Timestamp handling
                  09:17:11,610 INFO  [Version] Hibernate Commons Annotations 3.1.0.GA
                  09:17:11,625 INFO  [Version] Hibernate EntityManager 3.4.0.GA
                  09:17:11,781 WARN  [Ejb3Configuration] Persistence provider caller does not impl
                  ement the EJB3 spec correctly. PersistenceUnitInfo.getNewTempClassLoader() is nu
                  ll.
                  09:17:12,078 INFO  [AnnotationBinder] Binding entity from annotated class: org.j
                  boss.northwind3.Employees
                  09:17:12,203 INFO  [EntityBinder] Bind entity org.jboss.northwind3.Employees on
                  table Employees
                  09:17:12,781 INFO  [CollectionBinder] Mapping collection: org.jboss.northwind3.E
                  mployees.employeeses -> Employees
                  09:17:12,797 INFO  [CollectionBinder] Mapping collection: org.jboss.northwind3.E
                  mployees.employeeses_1 -> Employees
                  09:17:12,797 INFO  [CollectionBinder] Mapping collection: org.jboss.northwind3.E
                  mployees.employeeses_2 -> Employees
                  09:17:12,813 INFO  [Version] Hibernate Validator 3.1.0.GA
                  09:17:12,922 INFO  [HibernateSearchEventListenerRegister] Unable to find org.hib
                  ernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Searc
                  h is not enabled.
                  09:17:12,938 INFO  [ConnectionProviderFactory] Initializing connection provider:
                  org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
                  09:17:12,953 INFO  [InjectedDataSourceConnectionProvider] Using provided datasou
                  rce
                  09:17:15,125 INFO  [SettingsFactory] RDBMS: Microsoft SQL Server, version: 9.00.
                  4035
                  ...
                  ...

                  Thanks for looking at this for me.
                  Pete
                  • 6. Re: Persistent Class or ResultList problem
                    ZHIGUO LI Newbie

                    I also encountered the same problem, when I change to the JBOSS version JBOSS4.2 time is to run, and in not JBOSS4.2 in, they will run out of this problem, I was automatically generated through the CRUD code, this problem how to solve problems, I suspect the problem is a new version of hibernate


                    Click HELP for text formatting instructions. Then edit this text and check the preview.