Package de.xima.fc.persistence.tx
Annotation Type JpaTransactional
-
@Inherited @InterceptorBinding @Retention(RUNTIME) @Target({METHOD,TYPE}) public @interface JpaTransactional
Runs a method as a unit of work in a JPA transaction of the system database, the same wayJpaTransactionRunner.inTransaction(JpaWork)does: the transaction of the calling thread is taken part in if there is one and a new one is opened otherwise, it is committed when the method returns and rolled back when the method throws.Within such a method, an injected
EntityManageris the entity manager of that transaction, so a DAO needs nothing but the entity manager to work with. Outside a transaction, using an injected entity manager fails.Return DTOs, never entities or lazy proxies. Entities are detached once the transaction is over and an unresolved lazy association then fails on access.
On a class, every method of that class is run as a unit of work. Only calls that go through the bean's CDI reference are covered: a method invoked on
thisfrom within the same bean is not.- Since:
- 8.5.6
- Author:
- Norman Lorenz