zoukankan      html  css  js  c++  java
  • Validation failed for query for method public abstract boxfish.bean.Student boxfish.service.StudentServiceBean.find(java.lang.String)!

    转自:https://blog.csdn.net/lzx925060109/article/details/40323741

    1、

    Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'studentServiceBean': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract boxfish.bean.Student boxfish.service.StudentServiceBean.find(java.lang.String)!

    原因:bean类中的扩展查询方法的query语句中的sql语句存在错误。

    查询语句应该为select    s   from  Student s where s.id=?1这种样式。其中表明Stduent必须和实体类名完全相同,否则报错。

    2、Executing an update/delete query; nested exception is javax.persistence.TransactionRequiredException: Executing an update/delete query。

    原因:事务需求异常。或许是业务逻辑类为注解为@Transactional

    样例:

    @Repository
    @Transactional
    public interface StudentServiceBean extends JpaRepository<Student,Long> {
        @Query("select s from Student s where s.username=?1")
        public Student find(String username);
        @Modifying
        @Query("update Student s set s.password=?1 where s.id=?2")
        public int update(String password, Long id);
    }

  • 相关阅读:
    Delphi WebService连接数据库
    编写一个单独的Web Service for Delphi7(步骤)
    Delphi stdCall意义
    Delphi WEB APP DEBUGGER是如何使用的
    用delphi的THTTPRIO控件调用了c#写的webservice。
    Delphi 编写的Web Service
    Delphi WebService 中 Web App Debugger 的建议
    flex布局浅谈和实例
    IOS开关效果
    文字渐变和边框渐变
  • 原文地址:https://www.cnblogs.com/sharpest/p/7977038.html
Copyright © 2011-2022 走看看