Announcement Announcement Module
Collapse
No announcement yet.
Batch update Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      Thanks

      I use JDBCTemplate and it is working great.

      Comment

      Working...
      X