Я пытаюсь обновить столбец с суммой двух других столбцов (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 ]
Я провел некоторое исследование и обнаружил, что использование имени таблицы вместо сущности является обычной причиной этой ошибки, но это не так. так что, пожалуйста, другие идеи?