10.

Not supported for DML operations【Springエラー】

編集
この記事の要点
  • Hibernate の QueryExecutionRequestException: Not supported for DML operations
  • 原因: @QueryUPDATE / DELETE などの DMLを書いているが @Modifying が無い
  • 対処: 該当メソッドに @Modifying + @Transactional を付与
  • @Modifying のページも参照

 

エラー内容

Caused by: java.lang.RuntimeException: org.hibernate.hql.internal.QueryExecutionRequestException: Not supported for DML operations [UPDATE ... ];

nested exception is java.lang.IllegalStateException: org.hibernate.hql.internal.QueryExecutionRequestException: Not supported for DML operations [UPDATE ... ]

 

発生条件/原因/対処法

JPAで更新系のSQLを実行した際に発生するエラー。

更新系のメソッドに@Transactional がない もしくは @Transactional だけ付与されていると発生する。

以下のように@Modifyingを付与することで当エラーは解決する。

@Repository
public interface TestRepository extends JpaRepository{
    
    @Transactional

    @Modifying
    @Query("UPDATE TestEntity te SET te.colA = 1 WHERE te.id = :id")
    Integer updateTest(@Param("id")String id);
}

 

編集
Post Share
子ページ

子ページはありません

同階層のページ
  1. java.lang.IllegalStateException: CGLIB is required to process @Configuration classes
  2. Error creating bean with name 'org.springframework.aop.config.internalAutoProxyCreator': Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator
  3. No mapping found for HTTP request with URI ... in DispatcherServlet with name ...
  4. An internal error occurred during: "Building UI model". com/google/common/base/Function
  5. No identifier specified for entity : ...
  6. org.hibernate.hql.internal.ast.QuerySyntaxException: table_name is not mapped
  7. No compiler is provided in this environment
  8. java.sql.SQLException: The server time zone value ' ... ' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone
  9. Caused by: java.lang.RuntimeException: Executing an update/delete query
  10. Not supported for DML operations
  11. Field ... required a bean of type ... hat could not be found.
  12. Annotation-specified bean name ' ... ' for bean class [ ... ] conflicts with existing, non-compatible bean definition of same name and class [...]
  13. Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback.
  14. Exception in thread "main" java.lang.UnsupportedClassVersionError