wood burning stoves 2.0
The moose likes Object Relational Mapping and the fly likes Copying records from between 2 databases with JPA Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Copying records from between 2 databases with JPA" Watch "Copying records from between 2 databases with JPA" New topic

Copying records from between 2 databases with JPA

Michael Darsow

Joined: Mar 11, 2012
Posts: 4
Hi there!

I am new to this forum. Found this forum while looking for a solution for my problem. It looks very cool!

I need your help. I am doing JPA (eclipselink) since some weeks and i am wondering if there is a way to optimize my code.
Simplified i need to copy 500-1000 records from one database to another when the user presses on a button.

I have the entities A and B where A has a list of B.

So when the user starts the copying i load all B's from A with

and then i iterate over the list and persist each B.

This takes about 2-3 seconds for 500-1000 records. (just guessed the time, did not measure it)

My question is how this can be optimized?

The first thing i have in mind is the caching.
The caching is active, but i do not need all these records to get into the cache.
Is it possible to bypass the cache for loading and persisting these records?

And if there are more ways to optimize the process i would be very happy if you can help me out!

James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553


TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
I agree. Here's the link: http://aspose.com/file-tools
subject: Copying records from between 2 databases with JPA
It's not a secret anymore!