0

This is

  • What is the difference between non-jta-datasource and jta-datasource?

In the below code i didnt specified the persistence unit instead i have used non-jta- datasource how this working?is it possible to do like this?

<?xml version="1.0" encoding="UTF-8"?>
    <persistence version="2.0" 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"> 
        <persistence-unit name="bookPU" transaction-type="RESOURCE_LOCAL"> 
            <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> 
             <non-jta-data-source>java:/comp/env/jdbc/bookDS</non-jta-data-source>
            <class>com.admin.Author</class> 
            <class>com.admin.Book</class> 

            <exclude-unlisted-classes>false</exclude-unlisted-classes>
    </persistence-unit> 
    </persistence>
Lijo
  • 6,498
  • 5
  • 49
  • 60

1 Answers1

0

Your persistance.xml does contain persistance unit named bookPU. The first xml you have posted contains non jat datasource and second xml contains jta datasource. Normally non JTA datasource would be used in unit test cases where other resource like JMS need not fall under a single transaction. However in cases of actual application we use JTA data source where more than one XA resource like Database, JMS etc.. would be involved.
Please refer to the URL: Difference between a "jta-datasource" and a " resource-local " datasource? for difference between JTA and non-JTA datasource.

Community
  • 1
  • 1
thiyaga
  • 251
  • 1
  • 7
  • @404, I did not get what you meant by `code is reduced`? Whether you wish to use JTA or non -JTA depends on your need. If you wish for Two-Phase commit then you must go for JTA data source. If not non-JTA data source will fit. – thiyaga Dec 16 '13 at 06:22