5 Replies Latest reply on Oct 3, 2002 5:16 AM by hezekiel

    ReadOnly methods for entity beans

    annapurna

      This is related to my earlier message regarding the ejbStore control... I found that we can make some fields read-only, is there a way we can make some methods read-only in JBoss?

      If yes, can someone let me know how it is done.

      Thanks,
      Anna.

        • 1. Re: ReadOnly methods for entity beans
          qjafcunuas

          Hi
          You should declare NotSupported transaction in your ejb-jar.xml like this :
          <container-transaction>

          <ejb-name>yourEJBName</ejb-name>
          <method-name>yourMethod</method-name>

          <trans-attribute>NotSupported</trans-attribute>
          </container-transaction>

          Bruno

          • 2. Re: ReadOnly methods for entity beans
            annapurna

            Making the transaction not Supported ... doesnt this call the ejbStore but just do it outside a transaction?

            Actually I was trying out with Required as the transaction attribute assuming I start my transaction in the session bean and continue it in my calls to the entity bean so that any number of gets I make do not raise ejbStore method.But this didnt happen.

            Can anyone explain why?

            • 3. Re: ReadOnly methods for entity beans
              qjafcunuas

              Making the transaction not Supported ... does that you are in a read-only transaction.

              I don't know if it's possible that ejbStore isn't call.

              Nevertheless, you can define a boolean member variable to say if your data have been changed. So, in your ejbStore, you can evaluate your boolean to know if you have data to save.

              • 4. Re: ReadOnly methods for entity beans
                hezekiel

                NotSupported has nothing to do with ejbStore being called or not. It's a transaction attribute.

                Just out of the curiosity I tried that out and it didn't do the trick. Even though my bulk accessor method (getData()) was marked with NotSupported transaction attribute - the call to that method caused ejbStore to be fired.

                I think that the original question was that does JBoss support read-only methods (especially with BMP) like Web Logic and Resin do.

                The answer is no. But I sure hope that it would be supported in the future! No more 'isModified'-hacks...

                • 5. Re: ReadOnly methods for entity beans
                  hezekiel

                  Oops...
                  Just found out (from the Jboss book 30_x.pdf)
                  Go buy it! - it's well worht the cost! =)

                  <enterprise-beans>

                  <ejb-name>nextgen.EnterpriseEntity</ejb-name>
                  <jndi-name>nextgen.EnterpriseEntity</jndi-name>
                  <method-attributes>

                  <method-name>get*</method-name>
                  <read-only>true</read-only>


                  <method-name>anotherReadOnlyMethod</method-name>
                  <read-only>true</read-only>

                  </method-attributes>

                  </enterprise-beans>