|
Many applications make use of multiple datastores. It is a common requirement to be
able to replicate parts of one datastore in another datastore.
Obviously, depending on the datastore, you could make use of the datastores own
capabilities for replication. DataNucleus provides its own extension to JDO to
allow replication from one datastore to another. This extension doesn't restrict you to
using 2 datastores of the same type. You could replicate from RDBMS to XML for example,
or from MySQL to HSQLDB.
The following sample code will replicate all objects of type
Product
and
Employee
from PMF1 to PMF2. These PMFs are created in the normal way
so, as mentioned above, PMF1 could be for a MySQL datastore, and PMF2 for XML.
By default this will replicate the complete object graphs reachable from these
specified types.
import org.datanucleus.jdo.JDOReplicationManager;
...
JDOReplicationManager replicator = new JDOReplicationManager(pmf1, pmf2);
replicator.replicate(new Class[]{Product.class, Employee.class});
|
|