JPA dynamic persistence unit name

后端 未结 4 709
长发绾君心
长发绾君心 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:37

    Just an idea, not sure if it'll help: You may open a inputStream to read the persistence.xml file and replace these lines:

    
    
    
    
    

    Then splash a connection config screen where the user logs in, and set the connection according to the user privileges on that file, then start the main application

    Not sure if that will help, it's just and idea. Depends on your application and business logic.

提交回复
热议问题