Results 1 to 3 of 3

Thread: Batch update

  1. #1

    Default Batch update

    Hi

    I am using Hibernate with Spring and most of the time I use getHibernateTemplate to perform save/update. However I am facing a problem where I have to execute this query:

    Code:
    update user set score = 5 where score = :oldScore

    Where oldScore is 3

    What is the best way to execute this? Do I need to use Spring's JDBCTemplate()? I also looked at HibernateCallback but don't know how to make it execute such query.

    Thanks.

  2. #2
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    Using hibernate you should execute a select query
    Code:
    from User u where score = :score
    then iterate over the results and edit the score then persist / save the entities. If you have to iterate over a large amount of entites, the performances of your application may suffer a lot. In such case, It is a good idea to use Spring JDBC Abstraction Layer.
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  3. #3

    Default

    Thanks

    I use JDBCTemplate and it is working great.

Similar Threads

  1. batch update error using Hibernate 3
    By sbmahs in forum Data
    Replies: 1
    Last Post: Jun 17th, 2006, 01:02 PM
  2. Replies: 1
    Last Post: Jul 3rd, 2005, 04:08 PM
  3. Replies: 1
    Last Post: Apr 29th, 2005, 05:39 PM
  4. Force commit in batch update
    By mingshun in forum Data
    Replies: 3
    Last Post: Oct 24th, 2004, 07:09 AM
  5. Batch Update in ASA
    By schiremath in forum Data
    Replies: 7
    Last Post: Aug 23rd, 2004, 01:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •