Spring + Hibernate + JPA: How to reload EntityManagerFactory at runtime

一世执手 提交于 2019-12-05 12:32:56

I don't see any other solution besides reloading entire context.

All other practices could lead to memory leaks (on connections for example) or to all sorts of ClassNotFound and other things just image what will happen during a tx when you're trying to reconfigure the entitymanager alone

One solution I can think of is to "isolate" entire bean definition of the data-layer and replace the beans themselves thus avoiding a full app-context reload.

You can accomplish or by trying to create a new ApplicationContext, adding your data layer beans and replacing existing ones or by using a bunch of interfaces (for entitymanager, ds etc..) and replacing their implementation @ runtime (but will require a lot of work..)

you just need to make sure you're reloading the EntityManager + TX + DS (and perhaps other things I've forgot)

HTH

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