Spring @Transactional not creating required transaction

后端 未结 3 1288
悲&欢浪女
悲&欢浪女 2021-02-07 11:59

Ok, so I\'ve finally bowed to peer pressure and started using Spring in my web app :-)...

So I\'m trying to get the transaction handling stuff to work, and I just can\'t

3条回答
  •  执笔经年
    2021-02-07 12:26

    The problem is likely caused by a combination of you annotating a protected method, and using proxy-target-class="true". That's a bad mix. The transactional proxy generated by Spring will only work properly with public annotated methods, but it won't complain if they're not.

    Try either making the saveOrUpdate() method public or, better yet, define an interface for your DAO, and remove the proxy-target-class="true" setting. This is the safest, most predictable technique.

提交回复
热议问题