cart55free99 2011-06-05 19:56
浏览 246
已采纳

hibernate已发出sql语句 但是无数据插入 不知道Spring事务管理哪里有错

这个是我的applicationContext 配置文件

[code="XML"]
<?xml version="1.0" encoding="UTF-8"?>
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">

<bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="configLocation" value="classpath:hibernate.cfg.xml" />
    <property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration" />
</bean>

<bean id="txManager"
    class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:advice id="txAdvice" transaction-manager="txManager">
    <tx:attributes>
        <tx:method name="save*" propagation="REQUIRED" />
        <tx:method name="delete*" propagation="REQUIRED" />
        <tx:method name="update*" propagation="REQUIRED" />
        <tx:method name="merge*" propagation="REQUIRED" />
        <tx:method name="find*" propagation="REQUIRED" />
        <tx:method name="get*" propagation="SUPPORTS" />
        <tx:method name="search*" propagation="SUPPORTS" />
        <tx:method name="show*" propagation="SUPPORTS" />
    </tx:attributes>
</tx:advice>
<aop:config>
    <aop:pointcut id="interceptorPointCuts" expression="execution(* dao.impl.*.*(..))" />
    <aop:advisor advice-ref="txAdvice" pointcut-ref="interceptorPointCuts" />
</aop:config>
<!--事务管理配置结束 -->

<bean id="baseDAO" class="dao.BaseHibernateDAO"></bean>
<bean id="roleDAO" class="dao.TbRoleDAO"></bean>


[/code]

TbPermissionDAO 也确实放在了 dao.impl中

下面是我测试用到的方法
[code="java"]
public class TbPermissionDAOTest extends TestCase {

// 权限管理 增加权限ok
 public void testSavePermission() {
 TbPermissionDAO permissionDAO = new TbPermissionDAO();
 TbPermission permission = new TbPermission();
 permission.setUri("n2");
 permissionDAO.save(permission);
 }

}

[/code]

最后有输出语句 JUnit也显示正常。
Hibernate: insert into psoftee.tb_permission (uri) values (?)

&& 应该不是唯一键的问题, 因为我手动提交事务的话, 是可以插入数据的

  • 写回答

3条回答

  • 华子82 2011-06-07 10:37
    关注

    [code="java"]




    [/code]

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作