"The transaction-type attribute is used to specify whether the entity managers provided by the entity manager factory for the persistence unit must be JTA entity managers or resource-local entity managers. The value of this element is JTA or RESOURCE_LOCAL. A transaction-type of JTA assumes that a JTA data source will be provided—either as specified by the jta-data-source element or provided by the container. In general, in Java EE environments, a transaction-type of RESOURCE_LOCAL assumes that a non-JTA datasource will be provided. In a Java EE environment, if this element is not specified, the default is JTA. In a Java SE environment, if this element is not specified, the default is RESOURCE_LOCAL." see Section 8.2.1.2, Page 312 from JSR-317
ref:http://www.adam-bien.com/roller/abien/entry/don_t_use_jpa_s
sample java app use RESOURCE_LOCAL
javaee better us: JTA, JTA either as specified by the jta-data-source element or provided by the container
相关推荐
<persistence-unit name="demo" transaction-type="JTA"> //其他配置省略 </persistence-unit> 如果使用RESOURCE_LOCAL管理事务,则配置代码如下所示:<persistence> <persistence-unit name="demo" ...
- `<persistence-unit>`:定义一个持久化单元,这是JPA的核心概念,可以看作是数据存储的逻辑分区。 - `<class>`:声明实体类,每个类对应数据库中的一个表。 - `<properties>`:设置持久化相关的属性,如数据库...
<persistence-unit name="titan" transaction-type="JTA"> <jta-data-source>java:/OracleDS</jta-data-source> </persistence-unit> </persistence> ``` 在上面的示例中,我们定义了一个名为“titan”的...
<persistence-unit name="titan" transaction-type="JTA"> <jta-data-source>java:/OracleDS</jta-data-source> </persistence-unit> </persistence> ``` 在这个例子中: - `name` 属性定义了持久化单元的...
- `<persistence-unit name="sample" transaction-type="RESOURCE_LOCAL">`:定义了一个名为 "sample" 的持久化单元,并指定了事务类型为本地事务。 #### 六、JPA HelloWorld 示例 下面是一个简单的 JPA Hello...
<persistence-unit name="myPersistenceUnit" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.jpa.HibernatePersistenceProvider <!-- 实体类 --> <class>com.example.Entity1</class> <class>...
<persistence-unit name="myPU" transaction-type="JTA"> <jta-data-source>java:jboss/datasources/MySqlDS</jta-data-source> <!-- 其他配置 --> </persistence-unit> ``` 其中,`myPU`是持久化单元的名称,`...
<persistence-unit name="myPersistenceUnit" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.ejb.HibernatePersistence <class>com.example.Customer</class> <class>com.example.Order</class> ...
<persistence-unit name="jun" transaction-type="RESOURCE_LOCAL"> <!-- 配置信息 --> </persistence-unit> ``` 在这个示例中,“jun”是持久化单元的名称,`transaction-type`属性定义了事务管理类型。...
<persistence-unit name="eqp_mgr" transaction-type="RESOURCE_LOCAL"> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl ,SoftReferenceSize=100"/> <!-- ...
<persistence-unit name="examplePU" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.jpa.HibernatePersistenceProvider <class>com.example.User</class> <!-- 数据库连接配置 --> </...
<persistence-unit name="jpa-example" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.ejb.HibernatePersistence <class>Department <class>Employee <property name="javax.persistence.jdbc...
<persistence-unit name="myPU" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.jpa.HibernatePersistenceProvider <class>com.example.User</class> <!-- 数据库连接配置 --> ...
<persistence-unit name="aaEJBPU" transaction-type="JTA"> <jta-data-source>java:/MySqlDS</jta-data-source> <property name="hibernate.hbm2ddl.auto" value="create-drop"/> </persistence-unit> </...
<persistence-unit name="myPU" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.jpa.HibernatePersistenceProvider <class>com.example.MyEntity</class> <property name="javax.persistence....
<persistence-unit name="examplePersistenceUnit" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.jpa.HibernatePersistenceProvider <class>com.example.Orders</class> <class>...