0

I'm sure this is something stupid, but I can't figure out why Hibernate is upset with my named query. Can someone please help me? Here's my query and the domain objects in reference, followed by the stacktrace.

@NamedQuery(name = "findSummaryReportRollups", query = "select new com.bean.SummaryReportRollup(org.region, org.market, header.projectionYearMonth, detailLineItems.attribute, sum(detailLineItems.value))  from Header header  INNER JOIN OrganizationExt org on header.location = trim(org.id) inner join header.detailLineItems detailLineItems " +
                                                       " where header.location in (:locations) group by org.region, org.market, header.projectionYearMonth, detailLineItems.attribute ")

Header

@Entity
@Table(name = "header")
@SequenceGenerator(name="header_seq", sequenceName="header_seq", allocationSize=1)
public class Header implements Serializable {

private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="header_seq")
@Column(name = "head_id", insertable = true, updatable = false)
private Long id;

@OneToMany(fetch = FetchType.EAGER, cascade={CascadeType.ALL})
@JoinColumn(name="head_id")
private List<DetailLineItem> detailLineItems;

@Column(name = "location", insertable = true, updatable = false)
private String location;

@Column(name = "entry_date", insertable = true, updatable = false)
private Date entryDate;

@Column(name = "dm_apprvl_date")
private Date dmApprovalDate;

@Column(name = "last_updated")
private Date lastUpdatedDate;

@Column(name = "proj_year_month", insertable = true, updatable = false)
private String projectionYearMonth;

@Transient
private Date projectionMonthDate;

/* some other stuff and methods */
}

Detail Line Item

@Entity
@Table(name = "detail")
@SequenceGenerator(name="detail_seq", sequenceName="detail_seq", allocationSize=1)
public class DetailLineItem implements Cloneable, Serializable {

private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="detail_seq")
@Column(name = "detail_id")
private Long id;

@ManyToOne
@JoinColumn(name="head_id", unique=false, nullable=false)
@JsonIgnore
private Header header;

@ManyToOne
@JoinColumn(name="attrib_id", unique=false, nullable=false)
private Attribute attribute;

@ManyToOne
@JoinColumn(name="status_id", unique=false, nullable=false)
private Status status;

private Double value;

/* some other stuff and methods */
}

OrganizationExt

@Immutable
@Table(name="STRDIR")
public class OrganizationExt implements Serializable {

private static final long serialVersionUID = -1064943317455028767L;

@Id
@Column(name="SYS_ID", insertable=false, updatable=false)
private String id;

@Column(name="MARKET", insertable=false, updatable=false)
private String market;

@Column(name="REGION", insertable=false, updatable=false)
private String region;

/* some other stuff and methods */
}

Stack trace

[8/19/13 20:39:19:890 CDT] 0000001b extension     E com.ibm.wsspi.webcontainer.extension.WebExtensionProcessor createServletWrapper Error occured while preparing the servlet for initialization. 
                             javax.servlet.ServletException: SRVE0207E: Uncaught initialization exception created by servlet
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:377)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.init(ServletWrapperImpl.java:165)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.initialize(ServletWrapper.java:1588)
at com.ibm.wsspi.webcontainer.extension.WebExtensionProcessor.createServletWrapper(WebExtensionProcessor.java:98)
at com.ibm.ws.webcontainer.webapp.WebApp.getServletWrapper(WebApp.java:936)
at com.ibm.ws.webcontainer.webapp.WebApp.getServletWrapper(WebApp.java:857)
at com.ibm.ws.webcontainer.webapp.WebApp.initializeTargetMappings(WebApp.java:538)
at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinish(WebApp.java:360)
at com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:292)
at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:99)
at com.ibm.ws.webcontainer.VirtualHostImpl.addWebApplication(VirtualHostImpl.java:167)
at com.ibm.ws.webcontainer.WSWebContainer.addWebApp(WSWebContainer.java:722)
at com.ibm.ws.webcontainer.WSWebContainer.addWebApplication(WSWebContainer.java:607)
at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:376)
at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:668)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1162)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1313)
at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:611)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startModule(ApplicationMgrImpl.java:1613)
at com.ibm.ws.runtime.component.ApplicationMgrImpl._startModule(ApplicationMgrImpl.java:1561)
at com.ibm.ws.runtime.component.ApplicationMgrImpl$ApplicationNotifier.classChanged(ApplicationMgrImpl.java:1776)
at com.ibm.ws.classloader.ClassLoaderManager.checkAndNotify(ClassLoaderManager.java:550)
at com.ibm.ws.classloader.ClassLoaderManager.access$000(ClassLoaderManager.java:82)
at com.ibm.ws.classloader.ClassLoaderManager$ReloadTimerTask.alarm(ClassLoaderManager.java:586)
at com.ibm.ejs.util.am._Alarm.run(_Alarm.java:127)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1527)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0' defined in ServletContext resource [/WEB-INF/spring/services-jta-context.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/spring/services-jta-context.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: projctnsUnit] Unable to build EntityManagerFactory
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:710)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:410)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:1588)
at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinish(WebApp.java:350)
... 18 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/spring/services-jta-context.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: projctnsUnit] Unable to build EntityManagerFactory
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:398)
at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:275)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.detectPersistenceExceptionTranslators(PersistenceExceptionTranslationInterceptor.java:139)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.<init>(PersistenceExceptionTranslationInterceptor.java:79)
at org.springframework.dao.annotation.PersistenceExceptionTranslationAdvisor.<init>(PersistenceExceptionTranslationAdvisor.java:70)
at org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor.setBeanFactory(PersistenceExceptionTranslationPostProcessor.java:99)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1439)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1408)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
... 30 more
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: projctnsUnit] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:915)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74)
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)
... 45 more
Caused by: org.hibernate.HibernateException: Errors in named queries: findSummaryReportRollups
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:515)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1750)
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:94)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905)
... 51 more
4

1 回答 1

0

除非您映射实体之间的关联,否则您似乎无法执行左连接。就我而言,OrganizationExt 未映射到 Header,即使该位置存在。

所以看起来我可能会创建一个包含这些信息的 Oracle 视图,并直接在其中创建一个 Hibernate 映射。

于 2013-08-20T02:38:59.973 回答