gpt4 book ai didi

postgresql - 组织.postgresql.util.PSQLException : No results returned by the query

转载 作者:行者123 更新时间:2023-11-29 11:30:25 36 4
gpt4 key购买 nike

嘿,每个人都试图在我的 spring boot 应用程序中使用 @Query 注释将数据插入表中,但我遇到了 postgres 异常:

org.postgresql.util.PSQLException:  No results returned by the query 

这是我的代码:

这是仓库

@Query(value="INSERT INTO \"FCT_BY_DEV\"(\"IdDev\", \"IdFonction\") VALUES (?, ?) ",nativeQuery=true)
public String isertfonctionstodev(int dev,int fonction);

这是 Controller :

@RequestMapping(value="/function/insert", method = RequestMethod.POST)
public String insererfonctions (int dev,int fonction){
System.out.println("dev="+dev+"fonction="+fonction);
fonctionRepository.isertfonctionstodev(dev, fonction);
System.out.println("********");
return "aaa";
}

我在 angularJs 中通过 $http 使用这个服务

$http.post("/function/insert?dev="+$scope.id+"&fonction="+$scope.idf);

最后这是服务器日志

dev=16006fonction=14
Hibernate: INSERT INTO "FCT_BY_DEV"("IdDev", "IdFonction") VALUES (?, ?)
2016-04-27 16:52:03.204 WARN 7036 --- [nio-8080-exec-2] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 0, SQLState: 02000
2016-04-27 16:52:03.204 ERROR 7036 --- [nio-8080-exec-2] o.h.engine.jdbc.spi.SqlExceptionHelper : Aucun résultat retourné par la requête.

数据是正确的,我用相同的值尝试了相同的查询,它起作用了,为什么 posgres 会产生这个异常,我该如何修复,感谢任何帮助

最佳答案

我认为修改查询必须用额外的注释

@Modifying

关于postgresql - 组织.postgresql.util.PSQLException : No results returned by the query,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36895282/

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