• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating optimal HQL Update Query

 
A Bose
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Running a web application displaying multiple lines of record.
Each record line have many editable fields.
Each record corresponds to a bean.

What is the effective way of determining which fields have changed so that minimum no of Hibernate update Query would be created/fired/executed?
 
Salil Vverma
Ranch Hand
Posts: 257
Hibernate Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

As while sending the object to business or presentation layer, we get the object detached from session and persistence context associated is destroyed.
I think, in hibernate, we should be able to achieve the updation of only modified column in following way -

By setting select-before-update option along with dynamic update to true. In this scenario, Hibernate will at first fire a select query to retrieve the record and check if data in bean has been updated ( by select-before-update) and if data has been updated then update query of selected column will be fired (by dynamic update).


Personally I would not recommend this approach.As these will add additional overhead by firing addition queries to check whether the state of object has changed. As you are working on a web-application, I would recommend using javascript and pointing out the changed records as soon as change happens in presentation layer and persisting only the changed records. This approach would provide you optimum performance.

Regards
Salil Verma
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic