integration overrides during JPA bootstrap ought to override all logically related settings

Description

Given this peristence.xml:

This should work to overwrite the jta-data-source.

But instead, it crashes in JSE and unit tests because it tries to resolve "java:jboss/datasources/ExampleDS" from JNDI. The `javax.persistence.jdbc.url` should overwrite the jta-data-source entry.

Even adding this doesn't fix it:

In Eclipse Link it's apparently possible to overwrite the persistence.xml's <jta-data-source> element: https://stackoverflow.com/a/20819336/472109

In Hibernate, that approach doesn't work: https://stackoverflow.com/questions/51514433/jpa-reuse-persistence-xml-with-jta-data-source-in-jse-and-junit-by-overriding-t

Environment

None

Activity

Show:
Steve Ebersole
September 24, 2019, 7:04 PM

Actually, nm. I was simultaneously working another issue regarding what `EMF#getProperties`returns. You mean that a DriverManager-based Connection provider should be used here. That’s true.

Gail Badner
October 5, 2019, 12:33 AM

It looks like this fix caused a failure in an EAP JPA test:
org.jboss.as.test.integration.jpa.cfgfile.CfgFileTestCase

That test uses a persistence.xml containing just the following property:
<property name="hibernate.ejb.cfgfile" value="hibernate.cfg.xml"/>

hibernate.cfg.xml contains the properties that are needed for the test.

When the test calls EntityManager.getEntityManagerFactory().getProperties(), null is returned, causing an NPE when the test checks the value of a property defined in hibernate.cfg.xml,

Steve Ebersole
October 6, 2019, 3:48 AM

Works for me, unless I missed something in your description. I added 2 new tests.

org.hibernate.orm.test.bootstrap.jpa.PersistenceUnitOverridesTests#testCfgXmlBaseline

org.hibernate.orm.test.bootstrap.jpa.PersistenceUnitOverridesTests#testIntegrationOverridesOfCfgXml

 

testCfgXmlBaseline seems to be what you describe. But it passes.

Gail Badner
October 7, 2019, 4:01 AM

, thanks for creating the new tests. I’ll have to look into this further on Monday.

Gail Badner
January 7, 2020, 10:07 PM

Fixed in 5.3 branch as well.

Assignee

Steve Ebersole

Reporter

Geoffrey De Smet

Fix versions

Labels

None

backPortable

Backport?

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure