Hi,
I've defined an entity with named query as follows
Code:
@Entity
@Table(name="CUSTOMER")
@NamedQuery(name="getAllCustomer",query="SELECT cust FROM CUSTOMER cust WHERE cust.STATUS=? AND cust.BILLING_CODE=?")
public class Customer implements Serializable {
// entity properties and JPA annotated getters/setters
}
when I attempt to start the application, Context initialization fails with following error:
Code:
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: travelRequestPersistenUnit] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:677)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:132)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:308)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
... 40 more
Caused by: org.hibernate.HibernateException: Errors in named queries: getAllCustomer
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:365)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
In [url="http://www.docjar.com/html/api/org/hibernate/impl/SessionFactoryImpl.java.html"]Hibernate code[/url], I found this:
Code:
480 // this will throw an error if there's something wrong.
481 try {
482 log.debug("Checking named query: " + queryName);
[b][color=#FF0000] 483 //TODO: BUG! this currently fails for named queries for non-POJO entities
[/color] 484 queryPlanCache.getHQLQueryPlan( qd.getQueryString(), false, [/b]CollectionHelper.EMPTY_MAP );
485 }
Any suggestions???