JPA using multiple database schemas

前端 未结 6 1031
花落未央
花落未央 2020-12-01 05:13

I\'m having a bit of trouble with one particular issue using JPA/Spring:

How can I dynamically assign a schema to an entity?

We have TABLE1 that belongs to s

6条回答
  •  醉梦人生
    2020-12-01 05:56

    I had the same problem I solved that with a persistence.xml in which I refer to the needed orm.xml files within I declared the db shema

    
    
        . . .
        ormOne.xml
        . . .
    
    
    
        . . .
        ormTwo.xml
        . . .
     
    
    

    now you can create a EntityManagerFactory for your special schema

    EntityManagerFactory emf = Persistence.createEntityManagerFactory("schemaOne");
    

提交回复
热议问题