7 Replies Latest reply on Sep 29, 2006 8:52 AM by mmarcom

    javax.persistence.PersistenceException: org.hibernate.except

    soundarya

      I get the following error when i run the portal application in JBoss
      I am using hypersonic sql as the database.
      javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query

      What exactly does the error mean?

      What is the workaround for this?

        • 1. Re: javax.persistence.PersistenceException: org.hibernate.ex
          mmarcom

          could you post query as well as saying which rc version are you using for EJB3?
          it could be that your query is wrong, or that you are using a newer query with an old ejb3 release...

          please full @NamedQuery, and then we'll see what's wrong

          rgds
          marco

          • 2. Re: javax.persistence.PersistenceException: org.hibernate.ex
            soundarya

            JBoss 4.0.4GA is being used and this is the error stack trace.

            javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
            Caused by: java.sql.SQLException: Table not found in statement [select license0_.id as id69_, license0_.date as date69_, license0_.key as key69_, license0_.expirationDate as expirati4_69_ from License license0_]
            at org.hsqldb.jdbc.Util.throwError(Unknown Source)
            at org.hsqldb.jdbc.jdbcPreparedStatement.(Unknown Source)
            at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
            at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.doPrepareStatement(BaseWrapperManagedConnection.java:349)
            at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.prepareStatement(BaseWrapperManagedConnection.java:337)
            at org.jboss.resource.adapter.jdbc.WrappedConnection.prepareStatement(WrappedConnection.java:187)
            at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:497)
            at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:415)
            at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139)
            at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1561)
            at org.hibernate.loader.Loader.doQuery(Loader.java:661)
            at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
            at org.hibernate.loader.Loader.doList(Loader.java:2145)
            ... 271 more

            • 3. Re: javax.persistence.PersistenceException: org.hibernate.ex
              mmarcom

              well appaently yo udont have the license table...for some reason........
              did yo uspecify @Table in hte ejb.?
              pls post ejb annotations..

              rgds
              marco

              • 4. Re: javax.persistence.PersistenceException: org.hibernate.ex
                soundarya

                the session bean is has these annotations.


                @Stateless
                public class LicenseOrganizerBean

                {
                @PersistenceContext
                private EntityManager entityManager;

                public License getLicense( Long id )
                {
                final List existing =
                entityManager.createQuery( "SELECT OBJECT(o) FROM License AS o WHERE o.id=:id" )
                .setParameter("id", id )
                .getResultList();
                if( existing.size() == 0 )
                {
                return null;
                }
                return (License) existing.get( 0 );
                }
                }

                • 5. Re: javax.persistence.PersistenceException: org.hibernate.ex
                  mmarcom

                  where is your License entity bean?
                  can you post annotations on this?

                  have you checked for samples of NamedQuery for EJB3?

                  hth
                  marco

                  • 6. Re: javax.persistence.PersistenceException: org.hibernate.ex
                    soundarya

                    Hi marco,
                    Thanks for the response. This runs perfectly on Windows 2000 but this exception is being thrown on Windows XP.

                    Here is the entity bean
                    @Entity
                    public class License implements Serializable
                    {
                    @Id
                    @GeneratedValue
                    private Long id;
                    private Date date;
                    private String key;
                    private Date expirationDate;
                    }

                    What do u mean by NamedQuery?

                    • 7. Re: javax.persistence.PersistenceException: org.hibernate.ex
                      mmarcom

                      Hello,
                      try to add @Table (name="License") to your license bean

                      i am assuming that you are uisng EJB3.0, aren't you?
                      so you can create @NamedQuery on your EEJB, and then use
                      entityManager.createNamedQuery().. check EJB3.0 spec

                      hth
                      marco