Yes. In JPA you use persistence units, which represent specific banks. If you want to specify more than one bank just declare more than one persistence unit (PU) and create the Entity managers for each of them. The persistence.xml file declaring Pus would look like this:
<persistence-unit name="pu1">
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost/banco1" />
<property name="javax.persistence.jdbc.user" value="admin" />
<property name="javax.persistence.jdbc.password" value="123456" />
<persistence-unit name="pu2">
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost/banco2" />
<property name="javax.persistence.jdbc.user" value="admin" />
<property name="javax.persistence.jdbc.password" value="123456" />
There to reference an entity that is in the bank 1 you only need to instantiate the pu1 in the creation of the Entity manager:
EntityManager emPU1 = Persistence.createEntityManagerFactory("pu1").createEntityManager();
For the entity that is in Bank 2 just refer to pu2:
EntityManager emPU2 = Persistence.createEntityManagerFactory("pu2").createEntityManager();
After consulting both entities, you can do your DE-PARA and persist as you wish the final result. I hope to have helped ^^
Your question is too broad. Well, I think the answer to this problem lies in this study: http://blog.caelum.com.br/accessingmultiplos-bancos-data-com-jpa-e-cdi/
– Marcos Sousa
Vlw @Marcos. I’ll read the article
– LucaoA