== Why is this an issue?

The use of a "RESOURCE_LOCAL" ``++persistence-unit++`` makes you responsible for your own entity management, which involves a lot of extra boilerplate code to get right. Instead, set this to "JPA" in a JavaSE environment or omit it altogether in a JavaEE environment, where "JPA" is the default.


=== Noncompliant code example

[source,java]
----
<persistence-unit transaction-type="RESOURCE_LOCAL">  <!-- Noncompliant -->
----


=== Compliant solution

[source,java]
----
<persistence-unit transaction-type="JTA">
----


ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

=== Message

Use "JTA" instead.


'''
== Comments And Links
(visible only on this page)

=== on 6 Feb 2017, 19:11:29 Daniel Ferreira Castro wrote:
Compliant Solution is not 

<persistence-unit transaction-type="JPA">


it should be <persistence-unit transaction-type="JTA">


The XSD associated with this XML defines as follows (Both 2.0 and 2.1)


            <xsd:attribute name="transaction-type" 

                           type="persistence:persistence-unit-transaction-type">

              <xsd:annotation>

                <xsd:documentation>


                  Type of transactions used by EntityManagers from this 

                  persistence unit.


                </xsd:documentation>

              </xsd:annotation>

            </xsd:attribute>


and



  <xsd:simpleType name="persistence-unit-transaction-type">

    <xsd:annotation>

      <xsd:documentation>


        public enum PersistenceUnitTransactionType {JTA, RESOURCE_LOCAL};


      </xsd:documentation>

    </xsd:annotation>

    <xsd:restriction base="xsd:token">

      <xsd:enumeration value="JTA"/>

      <xsd:enumeration value="RESOURCE_LOCAL"/>

    </xsd:restriction>

  </xsd:simpleType>

endif::env-github,rspecator-view[]
