Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
尝试更新sql表时发生java.lang.NullPointerException_Sql_Spring Boot_Jpa - Fatal编程技术网

尝试更新sql表时发生java.lang.NullPointerException

尝试更新sql表时发生java.lang.NullPointerException,sql,spring-boot,jpa,Sql,Spring Boot,Jpa,我正在尝试使用以下内容更新PA49_DebtColumn: -如果存在产品,则第二个表中的Pa49_首秀值 -如果前几行中存在产品,则从同一表中删除 -否则,请从同一张表中选择PA49_Actuel 请查看存储库中的代码 public interface FSrepository extends JpaRepository<FSmodel, String> { @Transactional @Modifying @Query("Update FSmodel FS Se

我正在尝试使用以下内容更新PA49_DebtColumn: -如果存在产品,则第二个表中的Pa49_首秀值 -如果前几行中存在产品,则从同一表中删除 -否则,请从同一张表中选择PA49_Actuel 请查看存储库中的代码

 public interface FSrepository extends JpaRepository<FSmodel, String> {
  @Transactional 
  @Modifying
  @Query("Update FSmodel FS Set FS.PA49_Debut = CASE WHEN EXISTES (SELECT 1 FROM ISmodel SI where FS.Partnumber=SI.Partnumber)" + 
        " THEN SI.PA49 " + 
        "WHEN EXISTS (SELECT 1 FROM FSmodel FS2 WHERE FS.Partnumber=FS2.Partnumber AND FS.id>FS2.id )" + 
        " THEN FS2.PA49_Debut "+
          " ELSE (FS.PA49_Actuel) "
        + "END" )
        void setPA49Debut(); ```
这就是错误所在

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'controller': Unsatisfied dependency expressed through field 'FSrepos'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'FSrepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract void com.example.demo2.repository.FSrepository.setPA49Debut()!
Caused by: java.lang.NullPointerException: null
任何帮助都将不胜感激。谢谢。

NullPointerException:null的解决方案是


试试@Queryvaue=您的查询在这里,nativeQuery=true

正如@stacker所说,但我发现我的代码中有很多错误,我将尝试解释它们,希望它能帮助其他人。 第一


存在拼写错误的情况。当存在@alex时,必须写为CASE

第二个是在select语句中使用SI,我通过添加一个新的select语句解决了这个问题。 第三个错误是,当存在时,通过子查询这些行中的同一个表来更新我的表,从FSmodel FS2中选择1,其中FS.Partnumber=FS2.Partnumber和FS.id>FS2.id+ 然后FS2.PA49_首次亮相 我找到了解决办法,也找到了解释 最终这是我的最终代码,它工作得很好 @交易的 @修改 @Queryvalue=Update FSmodel FS Set FS.PA49\u首秀=CASE+ 当存在时,从ISmodel SI中选择SI.Partnumber,其中FS.Partnumber=SI.Partnumber +然后从ISmodel S中选择不同的S.PA49,其中FS.Partnumber=S.Partnumber+ 当退出时,从中选择1,从FSmodel中选择*作为FSd,其中FS.Partnumber=FSd.Partnumber,FS.id>FSd.id +然后从FSmodel中的select*中选择不同的F.PA49_作为F,其中FS.Partnumber=F.Partnumber,FS.id>F.id+1+ ELSE FS.PA49_Actuel+END,nativeQuery=true
无效设置

try@Queryvaue=当EXISTES拼写错误时,您的查询将转到此处,nativeQuery=trueCASE。必须写在existhanks@stacker和@alex时,它解决了NullPointerException问题,但我有这个错误,现在无法执行语句;SQL[n/a];嵌套异常为org.hibernate.exception.sqlgrammareexception:无法执行语句java.sql.SQLSyntaxErrorException:字段列表中的未知列'SI.PA49'有什么想法吗?
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'controller': Unsatisfied dependency expressed through field 'FSrepos'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'FSrepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract void com.example.demo2.repository.FSrepository.setPA49Debut()!
Caused by: java.lang.NullPointerException: null