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

performance issue in one-to-many in hibernate

 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the better way to insert an object in one-to-many ?

for example, one Employee has many Task.

when we add one Task into Employee taskList, we have to load employee and its ALL task, and then save


The major performance issue is line 2. we need to load ALL task, maybe 1000, just for adding ONE task.

Do we have a better way to resolve this issue ?

Thanks.
 
tanay purwar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
simply create a new task set Its employee id and save it to database
 
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!