User: sylvain 
  Date: 00/05/31 17:51:24

  Modified:    src/java/org/ejboss/ejb EnterpriseBeanWrapper.java
  Log:
  Bug Fix : if a transaction-scoped method of a bean creates a new entity bean, we 
mustn't terminate the transaction after ejbPostCreate. We have to wait until the end 
of the encapsulating transaction.
  Otherwise the transaction would be terminated twice, which leads to an exception...
  
  Revision  Changes    Path
  1.23      +16 -14    ejboss/src/java/org/ejboss/ejb/EnterpriseBeanWrapper.java
  
  Index: EnterpriseBeanWrapper.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/ejboss/src/java/org/ejboss/ejb/EnterpriseBeanWrapper.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- EnterpriseBeanWrapper.java        2000/05/17 17:31:18     1.22
  +++ EnterpriseBeanWrapper.java        2000/06/01 00:51:24     1.23
  @@ -674,12 +674,26 @@
   
           TxInterposition txInterposition = new TxInterposition();
   
  +        // For entities, we load on a new transaction
  +
  +        boolean newTransaction = true;
  +
  +        // Is there a transaction in the methodInvocation?
  +
  +        PropagationContext pTransaction = methodInvocation.getPropagationContext();
  +
  +        if (pTransaction != null) {
  +    
  +            Tracer.trace(TracerConstants.LOG_DEBUG, "BeanWrapper", " setting 
propagation context on Thread");
  +        }
  +        
           // let's deal with the "special" methods
   
           if (methodInvocation.getName().equals("ejbPostCreate")) {
  -
  -            txInterposition.mustTerminateTransaction = true;
   
  +           //You can commit on postCreate but only if we don't have an 
encapsulating Tx
  +           if (pTransaction == null) txInterposition.mustTerminateTransaction = 
true;
  +               
               return txInterposition;
           }
   
  @@ -691,18 +705,6 @@
   
           }
   
  -        // For entities, we load on a new transaction
  -
  -        boolean newTransaction = true;
  -
  -        // Is there a transaction in the methodInvocation?
  -
  -        PropagationContext pTransaction = methodInvocation.getPropagationContext();
  -
  -        if (pTransaction != null) {
  -
  -            Tracer.trace(TracerConstants.LOG_DEBUG, "BeanWrapper", " setting 
propagation context on Thread");
  -        }
           
           // Do we have a running transaction associated with this bean?
           // This can only happen on Entity (since Session synchronize on the object)
  
  
  

Reply via email to