[hibernate-issues] [Hibernate-JIRA] Created: (EJB-372) Named query does not support entity attribute with generic type

louie (JIRA) noreply at atlassian.com
Thu Jul 17 15:22:47 EDT 2008


Named query does not support entity attribute with generic type
---------------------------------------------------------------

                 Key: EJB-372
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-372
             Project: Hibernate Entity Manager
          Issue Type: Bug
          Components: EntityManager
    Affects Versions: 3.3.2.GA
         Environment: hibernate-3.3.0.CR1, hibernate-annotations-3.4.0.CR1
            Reporter: louie
         Attachments: test-case.zip

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.


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list