Step by step:
- Go to http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#testcontext-tx
- Scroll down to "Avoid false positives when testing ORM code"
- Find how to include SessionFactory and flush() is used to avoid false positives if you are using Hibernate.
The information is good, but it is not applicable if you use JPA. To avoid false positives when using JPA (backed by Hibernate) I propose that you add a new snippet that the describes a different approach. Suggested implementation: