how to modify properties after create entity manager factory from persistence.xml

前端 未结 1 1667
感情败类
感情败类 2021-01-13 18:49

i have a persistence.xml in META-INF/ folder:



  

        
相关标签:
1条回答
  • 2021-01-13 19:20

    When you create the EntityManagerFactory, you can pass a set of properties that will override what is defined in persistence.xml, e.g.:

    Properties props = new Properties();
    props.setProperty("javax.persistence.jdbc.url", "test_url");
    _emf = Persistence.createEntityManagerFactory("dev", props);
    

    If you want to modify the connection properties after the EntityManagerFactory was created, you must recreate it by calling createEntityManagerFactory() again.

    0 讨论(0)
提交回复
热议问题