• 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

EJB3 -> Best optimizzed way for bulk insert ?

 
Ranch Hand
Posts: 1491
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which is the optimized way for bulk insert using EJB 3 ?
 
author & internet detective
Posts: 41878
909
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do youhave to use JPA (EJB 3)? I would use a batchupdate in direct JDBC for large batches of inserts. Or a direct SQL loader for still larger batches.
 
kri shan
Ranch Hand
Posts: 1491
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have to use JPA (EJB 3)
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

kri shan wrote:I have to use JPA (EJB 3)



If you need to insert a large number of objects of dis-associated objects then you might follow the advice you have already in earlier posts.

On the other hand, if you need to insert a large number of associated (aggregated) objects, such as invoices with their line items and their line item details, then you might design the objects with cascading insert and update. This would allow you to save many records by saving a root object, in the example above saving an invoice object would also save all of its children and their children. This is much faster than looping through the objects and saving them individually.
 
reply
    Bookmark Topic Watch Topic
  • New Topic