0 Replies Latest reply on Nov 4, 2003 12:24 PM by anis79

    Transactions : Assert Failed and wierd behavior from JBoss

    anis79

      Hi All,

      I am trying to catch server exceptions after setting a value to a CMP field which causes an SQLException.
      I have 2 entity bean : Professor and User. Professor have a CMR field user which refers to the related user bean.
      I have an SQL constraint on the Hypersonic DB telling that the username must be unique.

      When i try to modify the username of the professor putting a username that already exists, i get some wierd behavior for the app. server : The SQLException is generated and i get an empty user table.
      When i tried to set the transaction management to "RequiresNew" both on the user and professor bean, i got the exception below (even when i try to insert a correct value):
      *******************************************************
      null; CausedByException is: Store failed; CausedByException is: Assert failed: beginNestedTransaction in statement [UPDATE USERS SET USER_NAME='rossi' WHERE ID_USER=3]; - nested throwable: (javax.ejb.EJBException: Store failed; CausedByException is: Assert failed: beginNestedTransaction in statement [UPDATE USERS SET USER_NAME='rossi' WHERE ID_USER=3]); nested exception is: javax.ejb.EJBException: Store failed; CausedByException is: Assert failed: beginNestedTransaction in statement [UPDATE USERS SET USER_NAME='rossi' WHERE ID_USER=3]; - nested throwable: (javax.ejb.EJBException: Store failed; CausedByException is: Assert failed: beginNestedTransaction in statement [UPDATE USERS SET USER_NAME='rossi' WHERE ID_USER=3])
      ********************************************************

      When i try to set a wrong value (username already exists), i get the same error and the users table contains twice the old "correct value" replacing the first row in the table even if it's a different one... So i get the same entry twice in the table (with same ID_USER and USER_NAME, which violates 2 unicity constraints...) and Hypersonic does not complain about that...

      Here is what i atrying to do :
      - I have this table with these values :
      ID_USER USER_NAME PASSWORD
      --------- ------------- ------------
      0 admin admin
      1 monceur monceur
      2 rossi rossi

      - this is the professor table

      ID_PROFESSOR ID_USER NAME
      ---------------- --------- ------
      1 1 monceur
      3 2 rossi

      when i try to do this :
      update users set USER_NAME = "rossi" where ID_USER=1

      i get an SQLException and this is the user table i get :

      ID_USER USER_NAME PASSWORD
      --------- ------------- ------------
      1 monceur monceur
      1 monceur monceur
      2 rossi rossi

      So the admin user is thrown away and replaced by the same "correct" entry violating 2 integrity constraints...

      After defining the transaction management values to "RequiresNew", i unable to insert or update anything in the user table, and i get the exception mentioned before...

      Could anyone helps me to solve this please ? Please ask me if u need further details...

      Thanks in advance !

      Anis