2

I am using jHipster and it is great as most of the boiler-plate Java code is automatically generated.

In my application, I need two MySQL databases. How do I configure them? Should I have two different database config files for the two different schemas?

Also, jHipster uses Liquibase, so how do I change my DatabaseConfiguration class?

johnnyRose
  • 7,310
  • 17
  • 40
  • 61

2 Answers2

2
  • You will need to configure 2 datasources, 2 Hibernate sessions, 2 cache instances... This is going to be quite complex: first start with the datasources (obviously!).
  • Please note that transactions won't work between your two databases, so this can lead to some interesting bugs :-)

Another solution, which I would prefer, is to use something similar to Oracle DB Link. That would solve all those problems and be much easier to work on.

Community
  • 1
  • 1
Julien Dubois
  • 3,678
  • 1
  • 20
  • 22
0

I'm not sure, if you talk about spring, but since you added the spring tag, I assume you do.

As far as I see, the basic question is, wether you need an XA-transaction or not (update both databases within the same transaction). If you do, then you simply define your datasources with an appropriate MySql XA-Datasource and bind them to the same transactionmanger (which of course has to support XA-transactions).

If you do this configuration in one or more spring-config-xml files (or java classes, if you prefer annotation based spring configuration) is up to you.

Hansjoerg Wingeier
  • 4,274
  • 4
  • 17
  • 25