Two MySQL Database on Jhipster

我与影子孤独终老i 提交于 2019-12-06 10:06:29

问题


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?


回答1:


  • 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.




回答2:


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.



来源:https://stackoverflow.com/questions/31240475/two-mysql-database-on-jhipster

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!