• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Creating optimal HQL Update Query

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 257
Hibernate Oracle Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
The first person to drink cow's milk. That started off as a dare from this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic