I need help setting up an application which copyies a subset of data from our in-house (master) MS SQL database DB1 to another MySQL database DB2 which runs on a webserver to be used by an webapplication (i.e. I want to sync those two databases). The tables have the same name on both databases, although only a subset of the attributes/columns are defined on DB2. I'd like to use (xml-configured) spring, spring data jpa (i.e. the JpaRepository interfaces) and hibernate as jpa-provider, because I want to build up knowledge with these tools.
As far as I could pick up from other discussions, the basic idea is to define spring to use two entityManagerFactory beans using one distinc dataSource each (one for each database) according to:
spring jpa hibernate with more datasources
I could then inject the persistence-unit-specific EntityManagers and do database-operations using these. But I'd like to use the spring-data repositories: At the moment I have defined a JPA Entity incl. fields for all the tables/attributes I need on DB2. For each Entity, I've set up an @Repository-annotated interface which impements JpaRepository, these repositories are then injected into corresponding Service-classes.
Is there any way to inject these repositories into my servce layer an assign a persistence-unit (i.e. select the database I want to use) to them during injection? I could in principle define all repositories twice, once for each database usign the @PersistenceContext(name="NameOfPersistenceUnit") annotation, but I hoped that this would not be necessary.
Could someone outline how I could achive my goal using the named frameworks, or are there easier ways to copy data between two databases programmatically. Any help is appreciated.