2014-02-05 108 views
0

我正在嘗試一些關於spring mvc web應用程序的手。我寫在資料庫查詢部署Spring-mvc Web應用程序時出錯

@Query("select c.paymentDetailName from customAttribute c where c.entityId=?1 AND c.entityType=?2 and c.paymentDetailName != 'null'") 
    public List<String> getNonNullPaymenyDetaisName(String entityId,String entityType); 

和我的調試/部署失敗,出現以下錯誤:

SEVERE: Exception sending context initialized event to listener instance of classorg.springframework.web.context.ContextLoaderListener 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customAttributeService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customAttributeRepository': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: customattribute is not mapped [select c.paymentDetailName from customattribute c where c.entityId=?1 AND c.entityType=?2 and c.paymentDetailName != 'null'] 
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) 
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) 
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) 
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) 
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) 
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585) 
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) 
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:469) 
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383) 
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283) 
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111) 
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4961) 
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5455) 
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) 
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) 
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:634) 
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:671) 
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1840) 
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) 
at java.util.concurrent.FutureTask.run(FutureTask.java:262) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 
at java.lang.Thread.run(Thread.java:744) 

Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.cms.repository.CustomAttributeRepository com.ms.service.CustomAttributeService.customAttributeRepository; 
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customAttributeRepository': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: customattribute is not mapped [select c.paymentDetailName from customattribute c where c.entityId=?1 AND c.entityType=?2 and c.paymentDetailName != 'null'] 
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:506) 
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) 
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284) 
... 26 more 

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customAttributeRepository': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: customattribute is not mapped [select c.paymentDetailName from customattribute c where c.entityId=?1 AND c.entityType=?2 and c.paymentDetailName != 'null'] 
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:149) 
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102) 
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1442) 
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:305) 
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) 
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:848) 
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:790) 
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707) 
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478) 
... 28 more 

Caused by: java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: customattribute is not mapped [select c.paymentDetailName from customattribute c where c.entityId=?1 AND c.entityType=?2 and c.paymentDetailName != 'null'] 
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1364) 
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1300) 
at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:294) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:606) 
at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:365) 
at com.sun.proxy.$Proxy37.createQuery(Unknown Source) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 

任何想法?

+0

您可以在堆棧跟蹤中看到最後一個illegalArgumentException中的錯誤。請參閱清楚地寫入「customattribute未映射」。 –

回答

1

此片段在你的痕跡告訴你,你有沒有映射實體定義的查詢:

customattribute is not mapped [select c.paymentDetailName from customattribute c 
+0

如何映射customattribute。我有我的數據庫customattribute表,我想獲取其中的paymentDetails不爲null的細節。我在sql工作臺上運行了查詢,並且執行得很好 – user3265739

0

分享春天XML配置即調度的servlet。 您可能沒有將customattribute映射到表或未正確配置它。

相關問題