Enterprise Java Development@TOPIC@

Chapter 98. Server-side Resources

98.1. SQL DataSource (defined in Server - standalone.xml)
98.2. Server-side Persistence Units
98.2.1. transaction-type=JTA (default)
98.2.2. transaction-type=RESOURCE_LOCAL
98.3. persistence.xml Placement
98.3.1. EJB persistence.xml Placement
98.3.2. WAR persistence.xml Placement
98.4. Reference External @Entities
98.4.1. Reference External @Entities: EAR Deploy
98.4.2. Reference External @Entities: WAR Deploy
98.5. Summary

<subsystem xmlns="urn:jboss:domain:datasources:1.0">
    <datasources>
        <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
            <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>
            <driver>h2</driver>
            <security>
                <user-name>sa</user-name>
                <password></password>
            </security>
        </datasource>
        <drivers>
            <driver name="h2" module="com.h2database.h2">
                <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
            </driver>
        </drivers>
    </datasources>
</subsystem>
ejb-jpa-example-war
|-- META-INF
`-- WEB-INF
...
    `-- lib
        `-- ejb-jpa-example-blimpl-5.0.0-SNAPSHOT.jar

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0">

    <persistence-unit name="ejbjpa-hotel">
        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
        <jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>

        <!-- located in WEB-INF/lib/ejb-jpa-example-blimpl-${project.version}.jar -->
        <class>info.ejava.examples.ejb.ejbjpa.bo.Guest</class>
        <class>info.ejava.examples.ejb.ejbjpa.bo.Room</class>
        <class>info.ejava.examples.ejb.ejbjpa.bo.Floor</class>

        <properties>
            <property name="hibernate.dialect" value="${hibernate.dialect}"/>
...
        </properties>
    </persistence-unit>            
</persistence>