views:

31

answers:

1

We have a main mysql database which all of the applications within our organization need the data within this database. How can I config my java web application to use this database with it's specific database when I use Spring and Hibernate within my application? How can I config JPA annotations for example between CONTRACT table within my database and COUNTRY table within our main database? what's the best practice to do this?

+1  A: 

The best practice is not to use multiple databases.

You can have 2 DataSource instances and two SessionFactory / EntityManagerFactory + persistnece unit instances, but that will be a huge mess and you should not do it.

Instead you have two options:

  • all developers use the same development database server
  • duplicate the remote data locally
Bozho
We all use the same database server but there are a lot of applications so we should use different schemas. If duplicate the remote data locally, then after the changes occured in data within main database, the data that duplicated locally doesn't update!
nazila