SnS
SnS

Reputation: 175

Difference between @Transactional and @TransactionAttribute

I started persistence coding and I came across annotations such as @Transactional and @TransactionAttribute. I understand the basic functionality of these two annotations and also that they can be used at both class level and at the method level. What I would like to understand better is the difference between these two annotations. Any help would be appreciated. Thanks.

Upvotes: 9

Views: 6637

Answers (2)

VHS
VHS

Reputation: 10184

  • @TransactionAttribute is meant for EJB beans.
  • @Transactional is meant for CDI beans.

No, @Transactional should not be used for annotating EJB business methods. While Java Docs suggests, it may be used for EJB, the EJB specs suggests it should not be used for EJBs at present.

Upvotes: 2

Lars Behnke
Lars Behnke

Reputation: 1901

@TransactionAttribute is for EJB3 beans.

@Transactional is for POJOs (for example Seam, Spring/Hibernate).

Upvotes: 12

Related Questions