Default value for @TransactionAttribute
Asked Answered
M

1

5

I am using EcllipseLink 2.5 in my project. Default value for @TransactionAttribute, is required. If we define SessionBean as TransactionManagementType CONTAINER, do we still need to add @TransactionAttribute annotation for every method in SessionBean to support transactions? Is there anyway to add default configuration for all SessionBeans or whole class? I don't want to add @TransactionAttribute with every method in class.

Any help would be much appreciated.

Thanks

Mycah answered 19/12, 2014 at 19:50 Comment(0)
N
7

Default value for TransactionAttribute is REQUIRED. REQUIRED is also the default if no TransactionAttribute annotation is used and the EJB in question uses container managed transactions.

Marking the EJB with CONTAINER TransactionManagementType means that every method is transactional and by default using REQUIRED TransactionAttributeType. You may even skip the TransactionManagement annotation, since CONTAINER TransactionManagementType is enabled by default for EJBs. You may use the TransactionAttribute annotation to override the default.

You may use the TransactionAttribute annotation either on class or method level or both, in which case method annotation will override class annotation for the specific method.

Nutt answered 22/12, 2014 at 10:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.