Last active
May 28, 2018 12:44
-
-
Save csabasulyok/3d374696d28a2f246f31eef3a9dd6293 to your computer and use it in GitHub Desktop.
Persistence.xml with JTA AND RESOURCE_LOCAL units, configured in their own way
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<persistence version="2.1" | |
xmlns="http://xmlns.jcp.org/xml/ns/persistence" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence | |
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"> | |
<!-- JTA based persistence unit --> | |
<persistence-unit name="umaPu" transaction-type="JTA"> | |
<!-- the JNDI name of the data source for this persistence unit --> | |
<!-- it's defined in a -ds.xml file next to this one --> | |
<jta-data-source>java:jboss/datasources/umaDS</jta-data-source> | |
<!-- list of classes we want to manage with JPA --> | |
<class>edu.codespring.uma.backend.model.User</class> | |
<class>edu.codespring.uma.backend.model.Role</class> | |
<!-- only custom configs of jpa --> | |
<properties> | |
<!-- <property name="javax.persistence.schema-generation.database.action" | |
value="drop-and-create" /> --> | |
<property name="hibernate.show_sql" value="true"/> | |
</properties> | |
</persistence-unit> | |
<!-- local persistence unit --> | |
<persistence-unit name="umaPuLocal" transaction-type="RESOURCE_LOCAL"> | |
<!-- list of classes we want to manage with JPA --> | |
<class>edu.codespring.uma.backend.model.User</class> | |
<class>edu.codespring.uma.backend.model.Role</class> | |
<!-- configs of jpa, like driver class, server URL and credentials --> | |
<properties> | |
<property name="javax.persistence.jdbc.driver" value="org.h2.Driver" /> | |
<property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:uma;DB_CLOSE_DELAY=-1" /> | |
<property name="javax.persistence.jdbc.user" value="sa" /> | |
<property name="javax.persistence.jdbc.password" value="" /> | |
<property name="javax.persistence.schema-generation.database.action" | |
value="create" /> | |
<property name="hibernate.show_sql" value="true"/> | |
</properties> | |
</persistence-unit> | |
</persistence> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<datasources> | |
<!-- JTA datasource for EE deployment --> | |
<datasource jndi-name="java:jboss/datasources/umaDS" | |
pool-name="umaDS" | |
enabled="true" | |
use-java-context="true"> | |
<!-- a driver with this name must exist in WildFly's configuration --> | |
<!-- more info here: https://synaptiklabs.com/posts/adding-the-mysql-jdbc-driver-into-wildfly/ --> | |
<driver>h2</driver> | |
<connection-url> | |
jdbc:h2:mem:uma;DB_CLOSE_DELAY=-1 | |
</connection-url> | |
<security> | |
<user-name>sa</user-name> | |
<password></password> | |
</security> | |
</datasource> | |
</datasources> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment