Marking a method as RequiresNew, does not mean that the method is read-only, it just means that a new transaction must be started.  Since the entity bean is already in a transaction the second call with hang.  With JBoss 3.0, you can now define read-only methods, but I warn you, your test will still hang unless method 1 is a read-only method too.
 

<jboss>

    <enterprise-beans>

       <entity>

           <ejb-name>nextgen.EnterpriseEntity</ejb-name>

           <jndi-name>nextgen.EnterpriseEntity</jndi-name>

           <method-attributes>

               <method>

                   <method-name>get*</method-name>

                   <read-only>true</read-only>

               </method>

               <method>

                   <method-name>anotherReadOnlyMethod</method-name>

                   <read-only>true</read-only>

               </method>

           </method-attributes>

       </entity>

    </enterprise-beans>

</jboss>

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Alice Ad
Sent: Tuesday, July 09, 2002 5:45 PM
To: jboss
Subject: [JBoss-user] Are read only methods supposed to lock entity beans?

Hello,

The following code hangs because it first calls an entity bean instance's method that has "Required" attribute and then calls the same instance's method that has "RequiresNew" attribute. The 1st transaction is blocking the second one.

// the following code hangs
class SessionBean {
public void hasRequiredAttribute() {
entityBean.hasRequiredAttribute(); // method 1
// it hangs here !!
entityBean.hasRequiresNewAttribute(); // method 2
}
}


If method 1 above is a read only method, why is the entity bean locked? Shouldn't it allow another transaction from the same thread use the entity bean??

Thanks so much.



Do You Yahoo!?
New! SBC Yahoo! Dial - 1st Month Free & unlimited access

Reply via email to