tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From José Luis Cetina <>
Subject TransactionAttribute
Date Fri, 06 Sep 2013 00:09:36 GMT
Hi i have an EJB annotated with:


As you can see i don't mark the EJB with any TransactionAttribute, instead
i use
TransactionAttribute in every method when i need it, if i don't need any
transaction (because i will only read information from database) then i
don't use any TransactionAttribute in the method not event

But today i realized that i have a method that IS NOT annotated with
any TransactionAttribute (and the ejb class either) but in that method i
query an entity and change some values  (inside of the ejb method) of the
retrieved entity, i could see that my entity is committed with those
changes (this is not suppose to happens).

I know if i mark the EJB with TransactionAttribute.XXX all the methods will
use the same TransactionAttribute that is defined in the class, i know if i
have the TransactionAttribute in the ejb class and in the method too, the
method TransactionAttribute has major priority. But in my case
i don't have any TransactionAttribute in the ejb class and in the method.

Then why my entity is commited with those changes?, is the default value
for TransactionAttribute using TransactionManagementType.CONTAINER
is @TransactionAttribute(TransactionAttributeType.REQUIRED) or something
like that??

If i annotated my method
with @TransactionAttribute(TransactionAttributeType.NEVER) the entity is
never persisted (required behavior), but if i add
the @TransactionAttribute(TransactionAttributeType.REQUIRED) then the
entity is persisted.

My surprise is if i use
@TransactionAttribute(TransactionAttributeType.REQUIRED) the entity is
persisted but i never do a persist or merge, i know if the method never
throw an exception the transaction is commited, but i never do a

Do i have to mark all of my methods with
@TransactionAttribute(TransactionAttributeType.NEVER)?? if yes, then i can
assume that the default value for an EJB is @TransactionAttribute.REQUIRED??

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message