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.
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.
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
So I guess this will be a use at your own risk type query. As long as it is simple it will work.