I have spring-data and hibernate configured and running. I can save records using spring-data but for some reason I am not able to run query that will update all Boolean fields in a table.
I tried this:
@Query("update Content v set v.published = false where v.division = :division and v.section = :section")
void unPublishContent(@Param("division") String division,
@Param("section") String section);
I also tried this:
@Query("update Content v set v.published = 0 where v.division = :division and v.section = :section")
void unPublishContent(@Param("division") String division,
@Param("section") String section);
Parameters division and section are coming true but no change on the table.
p.s. I am also using mysql database.
I’m using Spring 3.1 and Spring JPA Data. I was having a similar problem. I was constantly getting an error while trying to update multiple records in 1 query.
So, I had something like this.
Error:
So, after googling for a while, I found out that you had to add @Modifying.
But then I was getting the following error:
So, I figured my problem was now a transaction problem and I went back to google to research it and found out that you have to add @Transactional now. It appears that @Modifying also requires @Transactional.
but then I got the following error:
Again I googled for a while and came to the conclusion that my configuration was wrong and it turned out to be true. I was missing some xml configs.
It was long journey but I finally got it working. I hope this will help someone, trying to “pay it forward” as many others have helped me with their wonderful blogs, answers and comments.