简体   繁体   English

非jta数据源如何工作?是否有必要在persistence .xml本身中提供持久性单元?

[英]How non-jta-datasource working ?is it necessary to provide the persistence unit inside persistence .xml itself?

This is 这是

  • What is the difference between non-jta-datasource and jta-datasource? non-jta-datasource和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? 在下面的代码中,我没有指定持久性单元,而是使用了非jta数据源,它是如何工作的?有可能这样做吗?

<?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>

Your persistance.xml does contain persistance unit named bookPU. 您的sistenceance.xml确实包含名为bookPU的持久性单元。 The first xml you have posted contains non jat datasource and second xml contains jta datasource. 您发布的第一个xml包含非jat数据源,第二个xml包含jta数据源。 Normally non JTA datasource would be used in unit test cases where other resource like JMS need not fall under a single transaction. 通常,非JTA数据源将用于单元测试用例,在这种情况下,其他资源(如JMS)不必属于单个事务。 However in cases of actual application we use JTA data source where more than one XA resource like Database, JMS etc.. would be involved. 但是,在实际应用中,我们使用JTA数据源,其中将涉及多个XA资源,例如数据库,JMS等。
Please refer to the URL: Difference between a "jta-datasource" and a " resource-local " datasource? 请参考URL: “ jta-datasource”和“ resource-local”数据源之间的区别? for difference between JTA and non-JTA datasource. 关于JTA和非JTA数据源之间的差异。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM