Hi Milan,

your'e right. The formulation of the first part of my answer is definitly 
wrong. In fact I wanted to point to the situation I mentioned in the second part
(but as I see now this is not the same problem as yours).
I tried to use the "Supports" attribute for a method inside a session bean that 
only had the task to retrieve data by reading some entities (CMP). In general 
this method should be called outside from any existing transaction and so there 
should'nt be opened a new one. While the entity has relations to other entities 
(CMR) the container threw the exception you mentioned ("CMR field Set must be 
used in same transaction ... " ).
So to get it working I had to change the attribute to "Required" although for 
my purpose I didn't need a transaction and therefore didn't want some.
I found this behaviour somewhat astonishing and I do not know whether it's 
according to the specs.
Do you know a reason for it?

regards
Michael
 

-----Ursprüngliche Nachricht-----
Von: Unger, Milan [mailto:[EMAIL PROTECTED]
Gesendet: Montag, 7. August 2006 11:27
An: user@geronimo.apache.org
Betreff: RE: container-transaction attributes per method


Hi Michael, 

IMO,  the Required means that container will initiate transaction (below I 
attached extract of section 17.6.2.7 from EJB 2.1 Spec where this is 
explicitely stated). There is other attribute "Mandatory" that works in the way 
you assumed. Starting user transaction from EJB business is prohibited by EJB 
Spec.

The problem with cmr field is more less clear, but what I want is to call time 
consuming operation from MDB which traverse through entity beans -- no 
transaction associated to avoid table locking -- while I need separate ACID 
transactions for every  entity to store changes made on it. Both operations 
should be on same the same session bean (the best solution).

I played a bit with transaction attributes and if I change transaction context 
of the all methods to Required (Style 1) and select particular methods with 
NotSupported attribute, than it works with one strange behaviour 

calling method with NotSupported attribute suppress transaction - ok,
calling method with Required attribute from method with NotSupported will have 
no associated transaction, but method called from this one will it have 
associated - in this case it is also not provided by client. 

Little bit tricky to get appropriate behaviour. 

Regards, Milan.  




 17.6.2.7 Transaction Attribute Summary
          The following table provides a summary of the transaction context 
that the container passes to the busi-
          ness method and resource managers used by the business method, as a 
function of the transaction
          attribute and the client's transaction context. T1 is a transaction 
passed with the client request, while T2
          is a transaction initiated by the container.

      Transaction Attribute Summary
                                                                   Transaction 
associated    Transaction associated
            Transaction attribute       Client's transaction       with 
business method      with resource managers
                                                  none                      
none                       none
                NotSupported
                                                   T1                       
none                       none
                                                  none                       T2 
                        T2
                Required
                                                   T1                        T1 
                        T1
                                                  none                      
none                       none
                Supports
                                                   T1                        T1 
                        T1
                                                  none                       T2 
                        T2
                RequiresNew
                                                   T1                        T2 
                        T2
                                                  none                      
error                      N/A
                Mandatory
                                                   T1                        T1 
                        T1
                                                  none                      
none                       none
                Never
                                                   T1                       
error                      N/A


-----Original Message-----
From: Ueberbach, Michael [mailto:[EMAIL PROTECTED]
Sent: po 7. 8. 2006 9:30
To: user@geronimo.apache.org
Subject: AW: container-transaction attributes  per method
 
Hello Milan,

as far as I can see there seem's to be an misunderstandig of the transaction 
attribute "Required". Setting this attribute means that there has to be an open 
transaction already, otherwhile the container will throw this exception. If 
"Required" ist set the caller of the method is responsible for the existence of 
the "required" transaction.
As I experienced there is a special point when using cmr: If you want to call a 
method that looks for an entity with relations to other entities, you are 
forced to set the "Required" attribute, even if you only want to read the data 
without changing them.

regards
Michael

-----Ursprüngliche Nachricht-----
Von: Unger, Milan [mailto:[EMAIL PROTECTED]
Gesendet: Samstag, 5. August 2006 12:36
An: user@geronimo.apache.org
Betreff: container-transaction attributes per method


Hallo, 

I have problem to define transaction attributes per session bean methods in 
geronimo 1.1. 

I set the transaction attributes (Style 1) for all methods to "Supports" and 
then set Style 2 attributes for some methods to "Required" (see below). Anyway, 
when calling that methods, there is no transaction associated with the method 
call, so I get "CMR field Set must be used in same transaction ... " exception 
-- the called CMP entity bean has "Required" transaction attributes.

Do you know a reason what is wrong?

Regards, Milan. 


<container-transaction>
            <method>
                <ejb-name>ProductFacadeBean</ejb-name>
                <method-name>storeProduct</method-name>
            </method>
            <trans-attribute>Required</trans-attribute>
        </container-transaction>
        <container-transaction>
            <method>
                <ejb-name>ProductFacadeBean</ejb-name>
                <method-name>storeLink</method-name>
            </method>
            <trans-attribute>Required</trans-attribute>
        </container-transaction>
        <container-transaction>
            <method>
                <ejb-name>ProductFacadeBean</ejb-name>
                <method-name>storeLinkWithProduct</method-name>
            </method>
            <trans-attribute>Required</trans-attribute>
        </container-transaction>
        <container-transaction>
            <method>
                <ejb-name>ProductFacadeBean</ejb-name>
                <method-name>*</method-name>
            </method>
            <trans-attribute>Supports</trans-attribute>
        </container-transaction>

Reply via email to