2 Replies Latest reply on Mar 2, 2004 12:48 PM by sago

    UPDATE on each row after SELECT in CMP-EJB

    prosis_de

      Hello,
      i discovered that JBoss 3.2.0rc2 executes an update statement for each row it has found after executing a select statement to fetch the table data.
      This update statement seems to update only the foreign-key fields. If a table doesn't have a fk field, no UPDATE will be executed. This happens for every EJB/table with a fk column.
      In my EJB, the fk field is mapped via a cmr field and i access the cmr field during the load process in my application only through the getter method. I never call the setter of the cmr field in my application.
      I have searched the forum but found nothing about this behavior. Does anyone know why JBoss fires these updates? Are they necessary or can i prevent them?

      Here is a sample output that JBoss has generated. adm_users is the table and contact_id is the fk of a relationship to another table. The pk of adm_users is user_id.

      18:23:35,485 DEBUG [findAll] Executing SQL: SELECT t0_u.user_id, t0_u.name, t0_u.created, t0_u.modified, t0_u.user_v, t0_u.firstname, t0_u.lastname, t0_u.xpassword, t0_u.email, t0_u.contact_id FROM ADM_USERS t0_u WHERE t0_u.user_v = '1'
      18:23:35,532 DEBUG [AdmUsers] Executing SQL: UPDATE ADM_USERS SET contact_id=? WHERE user_id=?
      18:23:35,532 DEBUG [AdmUsers] Rows affected = 1
      18:23:35,532 DEBUG [AdmUsers] Executing SQL: UPDATE ADM_USERS SET contact_id=? WHERE user_id=?
      18:23:35,548 DEBUG [AdmUsers] Rows affected = 1
      18:23:35,548 DEBUG [AdmUsers] Executing SQL: UPDATE ADM_USERS SET contact_id=? WHERE user_id=?
      18:23:35,548 DEBUG [AdmUsers] Rows affected = 1
      18:23:35,548 DEBUG [AdmUsers] Executing SQL: UPDATE ADM_USERS SET contact_id=? WHERE user_id=?
      18:23:35,548 DEBUG [AdmUsers] Rows affected = 1
      18:23:35,548 DEBUG [AdmUsers] Executing SQL: UPDATE ADM_USERS SET contact_id=? WHERE user_id=?
      18:23:35,548 DEBUG [AdmUsers] Rows affected = 1
      18:23:35,548 DEBUG [AdmUsers] Executing SQL: UPDATE ADM_USERS SET contact_id=? WHERE user_id=?
      18:23:35,563 DEBUG [AdmUsers] Rows affected = 1
      18:23:35,563 DEBUG [AdmUsers] Executing SQL: UPDATE ADM_USERS SET contact_id=? WHERE user_id=?
      18:23:35,563 DEBUG [AdmUsers] Rows affected = 1
      18:23:35,563 DEBUG [AdmUsers] Executing SQL: UPDATE ADM_USERS SET contact_id=? WHERE user_id=?
      18:23:35,563 DEBUG [AdmUsers] Rows affected = 1
      18:23:35,563 DEBUG [AdmUsers] Executing SQL: UPDATE ADM_USERS SET contact_id=? WHERE user_id=?
      18:23:35,563 DEBUG [AdmUsers] Rows affected = 1
      18:23:35,563 DEBUG [AdmUsers] Executing SQL: UPDATE ADM_USERS SET contact_id=? WHERE user_id=?
      18:23:35,579 DEBUG [AdmUsers] Rows affected = 1