简体   繁体   English

春天带有休眠的多个SessionFactory

[英]Multiple SessionFactory in spring with hibernate

I am trying to add two MySql database in spring project with hibernate. 我正在尝试在具有休眠状态的spring项目中添加两个MySql数据库。 My question is that what should i use multiple SessionFactory or go ahead with spring boot and why?. 我的问题是,我应该使用多个SessionFactory还是继续进行Spring Boot ?为什么? If i use sessionfacotry then will be there any performance issue on project or is there any other alternative that i can use for adding multiple database? 如果我使用sessionfacotry,那么项目是否会出现性能问题,或者是否可以使用其他替代方法来添加多个数据库?

you can add several persistence units, obviously each PersitenceContext must have its own properties (url, user, password, driver,...), for example: 您可以添加几个持久性单元,显然每个PersitenceContext必须具有其自己的属性(URL,用户,密码,驱动程序...),例如:

@PersitenceContext("a")
private EntityManager emA;

@PersitenceContext("b")
private EntityManager emB;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM