Dúvida rápida - EJB e transações [RESOLVIDO]

Olá amigos do fórum, venho a voces com uma dúvida rápida para a qual nao estou encontrando uma resposta adequada…entao venho aos mestres do GUJ. :lol:

Os métodos de um EJB são envolvidos em uma transação por default, ou APENAS se for utilizada a anotação @Transactional?

Obrigado colegas.

cara,

tem uma transação sim, REQUIRED

t+

[quote=alissonvla]cara,

tem uma transação sim, REQUIRED

t+[/quote]

Opa! valeu, cara

Mas entao, se eu nao colocar nem na classe nem no metodo @Transactional(REQUIRED), será criada a transação? Repetindo, se eu NAO incluir essa anotação…

Obrigado!

cara,

ela será criada sim, required é default.

t+

E se eu NAO quiser que aquele EJB rode com transacoes, eu teria obrigatoriamente que incluir @Transactional(NOT_SUPPORTS) ou @Transactional(SUPPORTS)?

cara,

segue as informações

NOT_SUPPORTED

The container invokes an enterprise bean method whose transaction attribute is set to the NOT_SUPPORTED value with an unspecified transaction context.

If a client calls with a transaction context, the container SUSPENDS the association of the transaction context with the current thread before invoking the enterprise bean’s business method. The container RESUMES the suspended association when the business method has completed. The suspended transaction context of the client is not passed to the resource managers or other enterprise bean objects that are invoked from the business method.

If the business method invokes other enterprise beans, the container passes no transaction context with the invocation.

SUPPORTS

The container invokes an enterprise bean method whose transaction attribute is set to SUPPORTS as follows:

If the client calls WITH a transaction context, the container performs the same steps as described in the REQUIRED case.

If the client calls WITHOUT a transaction context, the container performs the same steps as described in the NOT_SUPPORTED case. 

The SUPPORTS transaction attribute must be used with caution. This is because of the different transactional semantics provided by the two possible modes of execution. Only the enterprise beans that will execute correctly in both modes should use the SUPPORTS transaction attribute.

mais informações, http://java.boot.by/scbcd5-guide/ch09s03.html

t+

[quote=alissonvla]cara,

segue as informações

NOT_SUPPORTED

The container invokes an enterprise bean method whose transaction attribute is set to the NOT_SUPPORTED value with an unspecified transaction context.

If a client calls with a transaction context, the container SUSPENDS the association of the transaction context with the current thread before invoking the enterprise bean’s business method. The container RESUMES the suspended association when the business method has completed. The suspended transaction context of the client is not passed to the resource managers or other enterprise bean objects that are invoked from the business method.

If the business method invokes other enterprise beans, the container passes no transaction context with the invocation.

SUPPORTS

The container invokes an enterprise bean method whose transaction attribute is set to SUPPORTS as follows:

If the client calls WITH a transaction context, the container performs the same steps as described in the REQUIRED case.

If the client calls WITHOUT a transaction context, the container performs the same steps as described in the NOT_SUPPORTED case. 

The SUPPORTS transaction attribute must be used with caution. This is because of the different transactional semantics provided by the two possible modes of execution. Only the enterprise beans that will execute correctly in both modes should use the SUPPORTS transaction attribute.

mais informações, http://java.boot.by/scbcd5-guide/ch09s03.html

t+[/quote]

Beleza cara, valeu…na verdade eu conhecia esses comportamentos, mas fiquei com duvida sobre o que ocorreria quando o @Transactional fosse omitido. Legal…

Valeu pela força, alissonvla