Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

hibernate multiple records update in a single statement

 
somu sharma
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have table and want to update each Salary record for each ID

ID FirstName Salary
10 AAAA 10,000
15 BBBB 5000
17 CCCC 7000
19 DDDD 8000

But what happening is update statement is executed for each row.Suppose I have 1000 records then update statement is executing 1000 times.Is there any better way I can achive this.
I am doing as ,

Is there way i can optimize this code ?

Thanks
 
Piyush Mangal
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try using hql if you want to update all the records at once.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!