日期:2014-05-18  浏览次数:20707 次

Struts2+spring3.1+jpa事务不提交的问题
环境:
STRUTS 2
SPRING 3.1
JPA 1.0 HIBERNATE 3.3

persistence.xml文件

<?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_1_0.xsd" version="1.0">
    
<persistence-unit name="aims" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>org.niux.aims.models.Menu</class>
<class>org.niux.aims.models.EntityType</class>
<class>org.niux.aims.models.Auth</class>
<class>org.niux.aims.models.Logs</class>
<class>org.niux.aims.models.Entitys</class>
<class>org.niux.aims.models.Account</class>
<class>org.niux.aims.models.Application</class>
<properties>
<property name="hibernate.connection.driver_class"
value="com.mysql.jdbc.Driver" />
<property name="hibernate.connection.url"
value="jdbc:mysql://localhost:3306/aims" />
<property name="hibernate.connection.username" value="root" />
<property name="hibernate.connection.password"
value="lyslmx0723" />
</properties>
</persistence-unit>

</persistence>


applicationContext.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"  
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
               xmlns:aop="http://www.springframework.org/schema/aop"  
               xmlns:tx="http://www.springframework.org/schema/tx"  
               xmlns:context="http://www.springframework.org/schema/context"  
               xmlns:p="http://www.springframework.org/schema/p"    
               xmlns:cache="http://www.springframework.org/schema/cache"    
               xsi:schemaLocation="http://www.springframework.org/schema/beans