Good morning everyone. I need a help from you guys...
# spring
c
Good morning everyone. I need a help from you guys. I'm developing a service using Kotlin and Spring with MySQL database, and Spring JPA, in my service I have some custom queries in my database like this one:
Copy code
@Modifying
    @Transactional
    @Query("DELETE FROM CollectionComicBook WHERE comic_book_id = ?1")
    fun deleteByComicBookId(comicBookId: Long): Int
When I run this query it works ok, I can see in my database that the value is being deleted, however my service return this error:
Copy code
"Modifying queries can only use void or int/Integer as return type!; nested exception is java.lang.IllegalArgumentException: Modifying queries can only use void or int/Integer as return type!
I've tried to change the return type to Long, Integer (from java), Unit and also leave it blank, but I'm still getting this error. I don't know what I can do to solve this. Anyone can help me with this?
g
have you tried no return?
c
Yes, I've tried no return. 😞
Well for some magic reason, this error is not happening anymore.
h
It most likely wasn't caused by this method – if the delete was executed in the DB, some other method used by your service was the issue.
c
I found what a did wrong, After some research I figured out that I was using the @Modifying annotation with a SELECT Query. causing the exception. I've removed the @Modifying annotations from my SELECT Queries, and now everything is working fine. Thank you for your help
👍 1