Hibernate Traps: @Transactional Integration Tests
Introduction After a short summer break we're getting back to tracking down the most sneaky and vicious traps that Java developer may stumble upon when using Hibernate. This time we are stretching the meaning of 'Hibernate trap' a little, because things that are described in this article require us to use Spring Framework in conjunction with Hibernate. Hibernate on its own doesn't offer any kind of automated Transaction management. However, given that 9 out of 10 Java devs uses Hibernate with Spring (or at least that's my assumption), I will happily carry on with the title as it is. Spring Transactions 1-0-1 Let's do a short recap on how Spring handles the @Transactional annotation: It uses AoP (Aspect-oriented Programming) to detect the methods and classes annotated with @Transactional . depending on whether we use Spring Aspects or AspectJ underneath, @Transactional will be detected on either Spring Beans with public methods only, or anywhere in the code...