javax.persistence.PersistenceException: org.hibernate.Hiberna teException: Errors in named queries: myquery

Hibernate JIRA | louie | 8 years ago
  1. 0

    [HHH-4153] Named query does not support entity attribute with generic type - Hibernate JIRA

    atlassian.net | 12 months ago
    javax.persistence.PersistenceException: org.hibernate.Hiberna teException: Errors in named queries: myquery
  2. 0

    We are using the generic to define a template for our entity. For example, we have the following abstract template class: @MappedSuperclass public abstract class AbstractIdentifier<T> { @Id @SequenceGenerator(name = "AbstractIdentifier", sequenceName = "identifier_id") @GeneratedValue(generator="AbstractIdentifier") private int id; @ManyToOne(optional=false) private T entity; .... } We have the following concrete class: @Entity @AssociationOverride(name="entity", joinColumns=@JoinColumn(name="myEntity")) public class Identifier extends AbstractIdentifier<MyEntity> { public MyEntity getMyEntity () { return super.getEntity(); } public void setMyEntity (final MyEntity myEntity) { super.setEntity(myEntity); } } If we defined a named query, such as: @NamedQueries( { @NamedQuery(name = "myquery", query = "select idf.myEntity from Identifier idf where idf.identifier = :identifier")}) Then, at runtime, we got the following error message: run: [java] Executing 'C:\Program Files\Java\jdk1.6.0_05\jre\bin\java.exe' with arguments: [java] '-classpath' [java] 'C:\workspaces\test-case\test-case\lib\antlr-2.7.6.jar;C:\workspaces\test-case\test-case \lib\cglib.jar;C:\workspaces\test-case\test-case\lib\commons-collections-3.1.jar;C:\workspaces\test- case\test-case\lib\commons-logging-1.1.1.jar;C:\workspaces\test-case\test-case\lib\dom4j-1.6.1.jar;C :\workspaces\test-case\test-case\lib\ejb3-persistence.jar;C:\workspaces\test-case\test-case\lib\free marker.jar;C:\workspaces\test-case\test-case\lib\hibernate-annotations.jar;C:\workspaces\test-case\t est-case\lib\hibernate-commons-annotations.jar;C:\workspaces\test-case\test-case\lib\hibernate-entit ymanager.jar;C:\workspaces\test-case\test-case\lib\hibernate-tools.jar;C:\workspaces\test-case\test- case\lib\hibernate3.jar;C:\workspaces\test-case\test-case\lib\hsqldb.jar;C:\workspaces\test-case\tes t-case\lib\javassist-3.6.0.GA.jar;C:\workspaces\test-case\test-case\lib\jboss-archive-browsing.jar;C :\workspaces\test-case\test-case\lib\jta.jar;C:\workspaces\test-case\test-case\lib\log4j-1.2.15.jar; C:\workspaces\test-case\test-case\lib\ojdbc14.jar;C:\workspaces\test-case\test-case\lib\persistence- api-1.0.jar;C:\workspaces\test-case\test-case\lib\persistence-api.jar;C:\workspaces\test-case\test-c ase\lib\slf4j-api-1.4.2.jar;C:\workspaces\test-case\test-case\lib\slf4j-log4j12-1.5.2.jar;C:\workspa ces\test-case\test-case\bin' [java] 'Tester' [java] [java] The ' characters around the executable and arguments are [java] not part of the command. [java] log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version ). [java] log4j:WARN Please initialize the log4j system properly. [java] Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.Hiberna teException: Errors in named queries: myquery [java] at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.j ava:737) [java] at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersis tence.java:121) [java] at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:52) [java] at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:34) [java] at Tester.main(Unknown Source) [java] Caused by: org.hibernate.HibernateException: Errors in named queries: myquery [java] at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:374) [java] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1304) [java] at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfigura tion.java:859) [java] at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.j ava:730) [java] ... 4 more [java] Java Result: 1 It looks like that hibernate can not parsing the generic type MyEntity correct. Please help. Thanks.

    Hibernate JIRA | 8 years ago | louie
    javax.persistence.PersistenceException: org.hibernate.Hiberna teException: Errors in named queries: myquery
  3. 0

    We are using the generic to define a template for our entity. For example, we have the following abstract template class: @MappedSuperclass public abstract class AbstractIdentifier<T> { @Id @SequenceGenerator(name = "AbstractIdentifier", sequenceName = "identifier_id") @GeneratedValue(generator="AbstractIdentifier") private int id; @ManyToOne(optional=false) private T entity; .... } We have the following concrete class: @Entity @AssociationOverride(name="entity", joinColumns=@JoinColumn(name="myEntity")) public class Identifier extends AbstractIdentifier<MyEntity> { public MyEntity getMyEntity () { return super.getEntity(); } public void setMyEntity (final MyEntity myEntity) { super.setEntity(myEntity); } } If we defined a named query, such as: @NamedQueries( { @NamedQuery(name = "myquery", query = "select idf.myEntity from Identifier idf where idf.identifier = :identifier")}) Then, at runtime, we got the following error message: run: [java] Executing 'C:\Program Files\Java\jdk1.6.0_05\jre\bin\java.exe' with arguments: [java] '-classpath' [java] 'C:\workspaces\test-case\test-case\lib\antlr-2.7.6.jar;C:\workspaces\test-case\test-case \lib\cglib.jar;C:\workspaces\test-case\test-case\lib\commons-collections-3.1.jar;C:\workspaces\test- case\test-case\lib\commons-logging-1.1.1.jar;C:\workspaces\test-case\test-case\lib\dom4j-1.6.1.jar;C :\workspaces\test-case\test-case\lib\ejb3-persistence.jar;C:\workspaces\test-case\test-case\lib\free marker.jar;C:\workspaces\test-case\test-case\lib\hibernate-annotations.jar;C:\workspaces\test-case\t est-case\lib\hibernate-commons-annotations.jar;C:\workspaces\test-case\test-case\lib\hibernate-entit ymanager.jar;C:\workspaces\test-case\test-case\lib\hibernate-tools.jar;C:\workspaces\test-case\test- case\lib\hibernate3.jar;C:\workspaces\test-case\test-case\lib\hsqldb.jar;C:\workspaces\test-case\tes t-case\lib\javassist-3.6.0.GA.jar;C:\workspaces\test-case\test-case\lib\jboss-archive-browsing.jar;C :\workspaces\test-case\test-case\lib\jta.jar;C:\workspaces\test-case\test-case\lib\log4j-1.2.15.jar; C:\workspaces\test-case\test-case\lib\ojdbc14.jar;C:\workspaces\test-case\test-case\lib\persistence- api-1.0.jar;C:\workspaces\test-case\test-case\lib\persistence-api.jar;C:\workspaces\test-case\test-c ase\lib\slf4j-api-1.4.2.jar;C:\workspaces\test-case\test-case\lib\slf4j-log4j12-1.5.2.jar;C:\workspa ces\test-case\test-case\bin' [java] 'Tester' [java] [java] The ' characters around the executable and arguments are [java] not part of the command. [java] log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version ). [java] log4j:WARN Please initialize the log4j system properly. [java] Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.Hiberna teException: Errors in named queries: myquery [java] at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.j ava:737) [java] at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersis tence.java:121) [java] at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:52) [java] at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:34) [java] at Tester.main(Unknown Source) [java] Caused by: org.hibernate.HibernateException: Errors in named queries: myquery [java] at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:374) [java] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1304) [java] at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfigura tion.java:859) [java] at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.j ava:730) [java] ... 4 more [java] Java Result: 1 It looks like that hibernate can not parsing the generic type MyEntity correct. Please help. Thanks.

    Hibernate JIRA | 8 years ago | louie
    javax.persistence.PersistenceException: org.hibernate.Hiberna teException: Errors in named queries: myquery
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Hibernate Exception errors in named queries

    Stack Overflow | 2 years ago
    org.hibernate.HibernateException: Errors in named queries: fetchCTCByReferenceIdByPendingApprov
  6. 0

    Errors in named queries: findByName in JBoss AS7 with Hibernate 3.6 and OJdbc6

    Stack Overflow | 2 years ago | Gaurav
    persistence.PersistenceException: [PersistenceUnit: manager1] Unable to build EntityManagerFactory

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.hibernate.HibernateException

      Errors in named queries: myquery

      at org.hibernate.impl.SessionFactoryImpl.<init>()
    2. Hibernate
      SessionFactoryImpl.<init>
      1. org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:374)
      1 frame
    3. Hibernate
      Configuration.buildSessionFactory
      1. org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1304)
      1 frame