Given this peristence In the {{persistence .xml :
{code } <persistence-unit name="optaweb-employee-rostering-persistence-unit" transaction-type="JTA"> < }, no {{ jta-data-source >java:jboss/datasources/ExampleDS</ }} or {{non- jta-data-source > }} is specified . .. </persistence-unit> {code}
This should work Attempting to overwrite use the jta-data-source.
{ code} Map<String, String> properties = new HashMap<>(); properties.put("javax.persistence.transactionType", "RESOURCE_LOCAL"); properties.put("javax.persistence.jdbc.driver", "org.hsqldb.jdbcDriver"); properties.put("javax.persistence.jdbc.url", "jdbc:hsqldb:mem:testdb"); properties.put("javax.persistence.jdbc.user", "sa"); properties.put("javax.persistence.jdbc.password", ""); EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory( "optaweb-employee-rostering-persistence-unit", properties); { code}
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:
{code jtaDataSource } properties.put } property ( "javax e . persistence g . jtaDataSource", ""); {code}
In Eclipse Link it's apparently possible to overwrite reference a JBoss EAP datasource) but the persistence property seems to be ignored . 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 This may or may not be related to HHH - reuse-persistence-xml-with-jta-data-source-in-jse-and-junit-by-overriding-t 12858. |
|