This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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
Author

Copying records from between 2 databases with JPA

Michael Darsow
Greenhorn

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!

Thanks!
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
See,

http://java-persistence-performance.blogspot.com/2011/06/how-to-improve-jpa-performance-by-1825.html

TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
 
 
subject: Copying records from between 2 databases with JPA