JPA dynamic persistence unit name

后端 未结 4 825
长发绾君心
长发绾君心 2021-02-04 06:17

I need a way to dynamically specify the persistence unit in a EJB.

Simplified example:

I have an application using multiple databases as data stores. Each of th

4条回答
  •  再見小時候
    2021-02-04 06:19

    You can use the same persistence unit for this. You just need to provide a properties Map when you call createEntityManagerFactory() with the url/datasource you want to use.

提交回复
热议问题