Otra pregunta SCBCD: Atributo de transacción MANDATORY

(Imagen: Paul Cézanne - Una Olimpia moderna)

La segunda (se los advertí xD):

A developer wants to achieve the following two behaviors for an EJB 3.0 session bean:

(1) If the client calls a business method with a transaction context, the container will invoke the enterprise bean's method in the client's transaction context.

(2)If the client calls a business method without a transaction context, the container will throw the javax.ejb.EJBTransactionRequiredException

Which transaction attribute should be used?

  • REQUIRED
  • SUPPORTS
  • MANDATORY
  • REQUIRES_NEW
  • NOT_SUPPORTED
Esta vez, comenzaremos por la respuesta correcta, que es la tercera. Como describe a detalle la pregunta, el atributo MANDATORY significa que el método EJB siempre debe ser parte de la transacción del cliente que lo invoca. El EJB no debe comenzar su propia transacción, ya que la transacción debe ser propagada desde el cliente. Y si se da el desafortunado caso que el cliente invocante (o sea ...el que invoca) no es parte de una transacción, la invocación fallará y se lanzará la excepción javax.ejb.EJBTransactionRequiredException.




Pregunta tomada de ExamWorx

Publicar un comentario