Changing Persistence Unit dynamically - JPA

前端 未结 4 1280
被撕碎了的回忆
被撕碎了的回忆 2020-11-29 03:26

Persistence units in persistence.xml are created during building the application. As I want to change the database url at runtime, is there any way to modify the persistence

4条回答
  •  难免孤独
    2020-11-29 04:19

    You can use Persistence.createEntityManagerFactory(Map) to pass properties to choose the database URL and other settings.

提交回复
热议问题