本文介绍了@交易注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


$ b

  • 将@Transactional注释添加到整个类中
  • 为每一种方法添加@Transactional注解?



使用spring和Hibernate?

@Transactional 所有方法都是事务性的。
如果您不这样做,您可以注释为只有你想要的那些方法。另外,您可以为每个方法指定不同的属性,例如 isolation , propagation , timeout ,...



另外,看看这个问题,这可能与它重复:


is there any difference between:

  • add "@Transactional" annotation to whole class
  • add for every single method "@Transactional" annotation ?

Using spring and Hibernate ?

解决方案

Basically, if you annotate the class with @Transactional all methods will be transactional.If you don't, you can annnotate as @Transactional only those methods you want to. Additionally, you can specify different attributes for each method, like isolation, propagation, timeout, ...

Also, take a look at this question, this is a possible duplicate of it: Hibernate transaction annotations in source — difference between class and method level use?

这篇关于@交易注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 18:04