gpt4 book ai didi

java - 带有参数 jsf 的 UPDATE HQL 查询中的 IllegalArgumentException

转载 作者:行者123 更新时间:2023-12-04 12:17:09 29 4
gpt4 key购买 nike

我有问题要问你,我的更新查询 (hql) 有什么问题?它早些时候工作正常,但是当我添加 @param 时显示错误。这是我的语法有问题吗?代码如下:

@Modifying
@Query("UPDATE InterimOrders io SET date12 = NULL,onceAMonthOpt12 = NULL, onceA2MonthOpt12 = NULL,yesNoOpt12 = NULL,totalCostOfExecusion12 = NULL,reportWithoutComments12 = NULL,reportWithoutCommentsForBusiness12 = NULL,information12 = NULL WHERE io.reportWithoutComments12 like '%Tak%' AND io.id = :id")
Integer updateUserDate12(@Param("id")Integer id);



我有以下错误:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'interimOrdersRepository': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: java.lang.NullPointerException
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:876)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:818)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:735)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)
... 38 more
Caused by: java.lang.IllegalArgumentException: java.lang.NullPointerException
at org.springframework.data.jpa.repository.query.SimpleJpaQuery.<init>(SimpleJpaQuery.java:73)
at org.springframework.data.jpa.repository.query.SimpleJpaQuery.fromQueryAnnotation(SimpleJpaQuery.java:132)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$DeclaredQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:114)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:160)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:68)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:280)
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:148)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:125)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:41)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
... 46 more
Caused by: java.lang.NullPointerException
at org.hibernate.hql.internal.ast.ParameterTranslationsImpl.getNamedParameterExpectedType(ParameterTranslationsImpl.java:87)
at org.hibernate.engine.query.spi.HQLQueryPlan.buildParameterMetadata(HQLQueryPlan.java:319)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:124)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:168)
at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:221)
at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:199)
at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1735)
at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:291)
at sun.reflect.GeneratedMethodAccessor38.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:365)
at com.sun.proxy.$Proxy40.createQuery(Unknown Source)
at sun.reflect.GeneratedMethodAccessor38.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:240)
at com.sun.proxy.$Proxy40.createQuery(Unknown Source)
at org.springframework.data.jpa.repository.query.SimpleJpaQuery.<init>(SimpleJpaQuery.java:69)
... 55 more



我的仓库:

@Transactional
public interface InterimOrdersRepository extends CrudRepository<InterimOrders, Integer>{
@Modifying
@Query("UPDATE InterimOrders io SET date12 = NULL,onceAMonthOpt12 = NULL, yesNoOpt12 = NULL,totalCostOfExecusion12 = NULL,reportWithoutComments12 = NULL,reportWithoutCommentsForBusiness12 = NULL,information12 = NULL WHERE io.date12 < DATE_FORMAT(CURRENT_DATE, '%Y-%m-%e') AND io.id = :id")
Integer updateDate12(@Param("id")Integer id);<br />
@Modifying
@Query("INSERT INTO InterimOrdersData (activityName,interimOrdersId,dateOfExecution,status,status1,status2,onceAMonthOpt12,onceA2MonthOpt12,yesNoOpt12,totalCostOfExecusion12,reportWithoutComments12,reportWithoutCommentsForBusiness12,information12,activityTitle, date12) SELECT activityName,id,dateOfExecution,status,status1,status2,onceAMonthOpt12,onceA2MonthOpt12,yesNoOpt12,totalCostOfExecusion12,reportWithoutComments12,reportWithoutCommentsForBusiness12,information12,activityTitle, date12 FROM InterimOrders io where io.reportWithoutComments12 like '%Tak%') AND io.id = :id")
Integer copyUserDate12(@Param("id")Integer id);

List<InterimOrders> findAll();



我的 bean :

@ManagedBean @ViewScoped 公共(public)类 InterimOrdersBean 实现序列化{

private static final long serialVersionUID = 8513710412378099452L;

public InterimOrdersRepository getInterimOrdersRepo(){
return (InterimOrdersRepository) RepositoryHelper.getRepo("interimOrdersRepository", InterimOrdersRepository.class);


}
public void UpdateDate12(Integer id) throws IOException{
System.out.println("Update Date 12");
System.out.println("id = "+id);
getInterimOrdersRepo().copyUserDate12(id);
System.out.println("copyUserDate12");

getInterimOrdRepo().updateUserDate12(id);
System.out.println("updateUserDate12");
return;

}}
您还需要什么吗?谢谢!

最佳答案

HQL/JPQL 查询中缺少或多余的括号会导致此类错误。

关于java - 带有参数 jsf 的 UPDATE HQL 查询中的 IllegalArgumentException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20054381/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com