Change values in persistence.xml from within the program

旧时模样 提交于 2019-12-11 06:05:30

问题


Is it possible to change values in persistence.xml from within the program that is using it ? If yes, i would appreciate some hints or/and links to read.


回答1:


Yes

    // connect to database
    log.info("Connecting to database @ " + dbUrl + " using " + dbUser + "/" + dbPass);
    emf = Persistence.createEntityManagerFactory("manager", Maps.create(
            "javax.persistence.jdbc.user", dbUser,
            "javax.persistence.jdbc.password", dbPass,
            "javax.persistence.jdbc.url", dbUrl
    ));



回答2:


not part of jpa spec, so no. some implementations may allow some updates ... e.g dayanucleus http://www.datanucleus.org/products/accessplatform_3_0/jpa/persistence_unit.html but what do u want to change?



来源:https://stackoverflow.com/questions/6355905/change-values-in-persistence-xml-from-within-the-program

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!