java - QuerySyntaxException: 表未映射 [更新表 BOMmodel 设置 PA13 = Materialvalue + ReqQTY ]
问题描述
如上所示,我正在尝试使用其他两列(Materialvalue,ReqQTY)的总和来更新一列
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Service;
import com.example.demo2.model.BOMmodel;
public interface BOMrepository extends JpaRepository<BOMmodel, String> {
@Modifying
@Query("Update Table BOMmodel Set PA13 = Materialvalue + ReqQTY ")
int updatePA();
}
实体看起来像这样
@Table(name = "bom_table")
@Entity
public class BOMmodel {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
public Long id;
public String ComponentNo;
public Float ReqQTY;
public String MatGroup;
public Float Materialvalue;
public Float PA13;
public String kw;
但我收到以下错误:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'controller': Unsatisfied dependency expressed through field 'BOMrepos'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'BOMrepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract void com.example.demo2.repository.BOMrepository.updatePA()!
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'BOMrepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract void com.example.demo2.repository.BOMrepository.updatePA()!
java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: Table is not mapped [Update Table BOMmodel Set PA13 = Materialvalue + ReqQTY ]
我做了一些研究,发现使用表名而不是实体是导致此错误的常见原因,但事实并非如此。那么请有其他想法吗?
解决方案
Update bom_table Set PA13 = Materialvalue + ReqQTY
用那个
推荐阅读
- delphi - 可以将 TScrollBox 控件的全部内容呈现到图像文件吗?
- java - 将数组作为参数传递,没有第一个元素 java
- javascript - 如何使用marginLeft而不是scrollLeft水平滚动div?
- c# - 使用临时数据实现 post-get-redirect 模式时的模型绑定错误
- python - 从其他文件导入 Python 函数会执行其他文件
- html - 空格随机出现在div之间的不同位置
- .net - 无法通过 NuGet 解决依赖关系
- node.js - Firebase 事务一次更新文档中的多个字段
- angular - Angular 8 Universal - 生产构建后./dist 中没有 index.html
- c++ - 条件 C++ 类成员定义