1
votes

I was going through the EJB 3.1 specifications and could not relate to the following scenarios.Could someone explain with an example

•If the client request is not associated with a transaction and the instance is already associated with a transaction T2, the container invokes the instance with the transaction that is associated with the instance (T2). This case can never happen for a stateless session bean, singleton session bean, or a message-driven bean: it can only happen for a stateful session bean.

•If the client is associated with a transaction T1, and the instance is already associated with a transaction T2, the container suspends the client’s transaction association and invokes the method with the transaction context that is associated with the instance (T2). The container resumes the client’s transaction association (T1) when the method (together with any associated interceptor methods) completes. This case can never happen for a stateless session bean, singleton session bean, or a message-driven bean: it can only happen for a stateful session bean.

If an EJB with a transaction-scoped persistence context invokes on a stateful session bean that uses an extended persistence context, an error is thrown.why?should not the stateless session bean's transaction be suspended and then invoke the method with the transaction context that is associated with the stateful session bean.

1

1 Answers

0
votes

What is the problem? It is about stateful session bean. Only such sort of bean can hold transaction between method invocation. So, if you call stateful session bean which already has active transaction, your method call will be executed inside stateful session bean transaction.