4 Replies Latest reply on Sep 6, 2002 4:39 PM by Dain Sundstrom

    CMR EJB QL row locking

    vishal Newbie

      Hello dsundstrom
      lets assume there are 3 entity beans (A,B,C) and all of them defined </row-locking> as true. there is a cmr relationship between A and B and also A and C.
      If i write ejbql to look for Object(C) something like this
      SELECT OBJECT(C) FROM cnCustomerSchema A, IN(A.addressDetails) B , IN(A.phoneDetails) C WHERE A.cnCustomer = ?1 and B.current_Flg ='F' and B.occupied_Flg ='T' and B.cnAddress_Type = ?2

      if i add FOR UPDATE at this end of this ejbql the ql will not get parsed . Do u think thats not the write way to define FOR UPDATE?

        • 1. Re: CMR EJB QL row locking
          vishal Newbie

          i have a method which is defined as read only in jboss.xml and which run this above ejbql.And the entity bean is defined as row locking in jbosscmp-jdbc.xml .
          now if i assumes that that the read only methods doesn;t included in any type of transactions or lock the bean within the transaction. every time jboss runs this ql it also runs this below query after parsed query is executed
          SELECT PHONE_NUMBER, EXTENSION, PHONE_TYP, U_VERSION, CNORIGIN, CNCUSTOMER FROM CNCUSTOMER_PHONE WHERE (CNCUSTOMER_PHONE=?) FOR UPDATE

          this means even if u have defined ur method as read only it will lock the rows.


          • 2. Re: CMR EJB QL row locking
            Dain Sundstrom Master

            The container configuration read-only is compeletely seperate from JBossCMP. We hope to fix this problem in JBoss 4. In the mean time I suppose it would be useful to be able to add a row-locing option to the query elements. If you agree post a feature request at source forge.

            • 3. Re: CMR EJB QL row locking
              vishal Newbie

              i think it depends on the EJBQL. If EQLQL has a relationship and we add FOR UPDATE to the query generated like for my case the query will not be valid query for the database.i tried the same query in ORACLE sqlplus and i got this result

              SELECT DISTINCT t0_phone.CNCUSTOMER_PHONE FROM CNCUSTOMER t1_cust, CNADDRESS t2_address, CNCUSTOMER_PHONE t0_phone WHERE (t1_cust.CNCUSTOMER = 10003 AND t2_address.CURRENT_FLG = 'F' AND t2_address.OCCUP_FLG = 'T' AND t2_address.ADDRESS_TYP = 216) AND (t1_cust.CNCUSTOMER=t0_phone.CNCUSTOMER AND t1_cust.CNCUSTOMER=t2_address.CNCUSTOMER) FOR UPDATE

              ERROR at line 1:
              ORA-01786: FOR UPDATE of this query expression is not allowed

              • 4. Re: CMR EJB QL row locking
                Dain Sundstrom Master

                So I guess this will be a use at your own risk type query. As long as it is simple it will work.