Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8529979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:09:09+00:00 2026-06-11T09:09:09+00:00

I have spring-data and hibernate configured and running. I can save records using spring-data

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T09:09:11+00:00Added an answer on June 11, 2026 at 9:09 am

    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.

    @Query("UPDATE User u SET u.state = ?1 WHERE u.server.id = ?2")
    public void updateAllUsers(long state, long serverid);
    

    Error:

    org.hibernate.hql.QueryExecutionRequestException: Not supported for DML operations
    

    So, after googling for a while, I found out that you had to add @Modifying.

    @Modifying  
    @Query("UPDATE User u SET u.state = ?1 WHERE u.server.id = ?2")
    public void updateAllUsers(long state, long serverid);
    

    But then I was getting the following error:

    ...    
    nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: Executing an update/delete query; 
    nested exception is javax.persistence.TransactionRequiredException: Executing an update/delete query
    ...
    

    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.

    @Modifying  
    @Transactional
    @Query("UPDATE User u SET u.state = ?1 WHERE u.server.id = ?2")
    public void updateAllUsers(long state, long serverid);
    

    but then I got the following error:

    No value for key [org.apache.commons.dbcp.BasicDataSource (...) ] bound to thread
    

    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.

    <beans:bean class="org.springframework.orm.jpa.JpaTransactionManager" id="transactionManager">
        <beans:property name="entityManagerFactory" ref="entityManagerFactory"/>
    </beans:bean>
    
    <tx:annotation-driven transaction-manager="transactionManager"/>
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am running some experiments using a Java program including Hibernate data storage. An
I'm using Spring data neo4j 2.1.0.BUILD-SNAPSHOT and Neo4j 1.6.1 server. I have a Friendship
I have been looking into Spring Social Facebook's publish(objectId, connectionName, data) API , but
I have a Spring/JPA application with Hibernate as the JPA provider. I've configured a
I have a Spring-MVC, Hibernate, (Postgres 9 db) Web app. An admin user can
I have an JPA/Hibernate/Spring/Tomcat web application with second level data cache enabled for performance
I have used Spring DATA JPA in my application, which is wrapper over hibernate.
I am trying to validate my form Data using Hibernate Validator in my Spring
I'm getting a LazyInitializationException in my Spring Application. I have the OpenEntityManagerInViewFilter configured so
i am using Spring.net 1.2 with NHibernate 2.0.1. Within my project i'am facing some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.