jpa - It is possible to override properties in a persistence.xml that is located in a jar dependency -
i have java-ee web application uses persistence unit packaged jar dependency (entity classes, ejb repositories, persistence.xml).
in order acceptance tests running web application need override property in packaged persistence.xml. specific need disable default active eclipselink shared object cache setting following property.
<property name="eclipselink.cache.shared.default" value="false"/>
this necessary because acceptance tests directly prepare/cleanup database dbunit. these modifications put eclipselink cache in stale state (because persistence unit not involved in these modifications).
is there way in java-ee (or glassfish specific) override properties in persistence.xml located in jar (starting web application war file, deployed when running tests)?
there may other ways, example building jar dependency specific test deployment, route seems complicated me override 1 property in persistence.xml.
you can pass properties map persistence.createentitymanagerfactory(). must manage persistence context (will not able inject it).
another option set property java system property (-d=), not override existing property in persistence.xml, work if property not in persistence.xml.
another option put sessioncustomizer or sessiontuner in persistence.xml allow own code modify configuration @ runtime.
Comments
Post a Comment