springbootjpaの@queryでSQL文を実行したいのですがエラーが出てその原因が分からない。
エラーを検索したが同様のエラーが出ている人がいなかったです。
下記がエラーになります。
org.h2.jdbc.JdbcSQLNonTransientException: メソッドはクエリしかサポートしていません。executeQueryのかわりに、excecute、またはexecuteUpdateを使用してください Method is only allowed for a query. Use execute or executeUpdate instead of executeQuery; SQL statement: DELETE FROM THREAD_FORM WHERE THREAD_ID IN (SELECT MIN(THREAD_ID) FROM THREAD_FORM); [90002-200] at org.h2.message.DbException.getJdbcSQLException(DbException.java:505) ~[h2-1.4.200.jar:1.4.200] at org.h2.message.DbException.getJdbcSQLException(DbException.java:429) ~[h2-1.4.200.jar:1.4.200] at org.h2.message.DbException.get(DbException.java:205) ~[h2-1.4.200.jar:1.4.200] at org.h2.message.DbException.get(DbException.java:181) ~[h2-1.4.200.jar:1.4.200] at org.h2.message.DbException.get(DbException.java:170) ~[h2-1.4.200.jar:1.4.200] at org.h2.command.Prepared.query(Prepared.java:231) ~[h2-1.4.200.jar:1.4.200] at org.h2.command.CommandContainer.query(CommandContainer.java:285) ~[h2-1.4.200.jar:1.4.200] at org.h2.command.Command.executeQuery(Command.java:195)
下記がソースです。
java
1public interface ThreadRepository extends JpaRepository<ThreadForm,Long> { 2 @Query(value="DELETE FROM THREAD_FORM WHERE THREAD_ID IN (SELECT MIN(THREAD_ID) FROM THREAD_FORM);", nativeQuery = true) 3 void threadIdMinDeleat(); 4} 5

回答2件
あなたの回答
tips
プレビュー