0
@Query(nativeQuery=true,value="update tbl_runningNumber set autoNum= autoNum+1 where cycle=:cycle and module=:module")
String updateByCycle(@Param ("module")String module,@Param("cycle") int cycle);

I want to update data form spring to database when i click on update at database is work normal but at my spring error messages

2023-02-01 16:17:47.651  WARN 21588 --- [nio-8082-exec-4] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 0, SQLState: null
2023-02-01 16:17:47.651 ERROR 21588 --- [nio-8082-exec-4] o.h.engine.jdbc.spi.SqlExceptionHelper   : The statement did not return a result set.
Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
  • Well, an `update` statement doesn't return a value, yet the return type of your method is `String`. What do you expect that to return? – Joachim Sauer Feb 01 '23 at 09:36
  • @Query(nativeQuery=true,value="update tbl_runningNumber set autoNum= autoNum+1 where cycle=:cycle and module=:module") String updateByCycle(@Param ("module")String module,@Param("cycle") int cycle); can i change my return String to another one ....? brother – Phortsophea MMO Feb 01 '23 at 09:42
  • when i follow this answer the error show ( Executing an update/delete query; nested exception is ) – Phortsophea MMO Feb 01 '23 at 10:06
  • Please [edit] your question to include any modifications you attempted and the complete stack trace & error message that you got. Giving us just a sliver of the error message and hoping that someone can guess what went wrong in the code that you didn't show is us a bit rude, to be honest. – Joachim Sauer Feb 01 '23 at 10:39

2 Answers2

0

Make return type for the method to void as the update query does not return anything.

Also for update query you should annotate method with below annotations along with @Query.

@Transactional
@Modifying
Alien
  • 15,141
  • 6
  • 37
  • 57
0

Try to annotate your update method with @Modifying annotation.

artiomi
  • 383
  • 2
  • 7