hibernate - Which is the more efficient way of updating data? -


there table named company_master having multiple rows each user_id. updating table , setting 1 of column false.

which way preferred ?

1) getting list<companymaster> company_master table , setting status field , , updating object in loop

2) writing directly query

query query= session.createquery("update companymaster set status=:status userid= :userid"); query.setparameterlist("status", false); query.setparameterlist("userid", 1); query.executeupdate();

if can, in case can , should, use writing directly query update or delete operation. don't have select records before , update them, it's slower direct update - select data don't need update / delete, don't need iterate in server side (as it's slower in performance in db side). might have case when need update big amount of records , in case select db in store in java memory, it's wasted memory comsuption.


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -