0 Replies Latest reply on Jan 23, 2003 2:24 AM by Andrea Peterlongo

    Jboss 3.0 Bug?: Unique Key Violation Error/TransactionRollba

    Andrea Peterlongo Newbie


      I have 2 entity beans, say ZipCode and City.
      ZipCode attributes are pk, description, cityPK while City attributes
      are pk and description.
      In the database schema ZipCode table there is an unique constrait for
      (description, cityPK) pair while, in the abstract schema, cityPK is a
      CMR field.
      The ZipCode EB uses ejbCreate(pk, description, cityPK) to set pk and
      description and ejbPostCreate(pk, description, cityPK) to set cityPK.

      A session bean exposes saveZipCode(ZipCode zip) method which throws a
      customize Exception, say BackEndException. BackEndException may be
      specialized according to the error catch during a ZipCode creation
      (ie Unique Key Violation, PK already present, etc)
      The body of saveZipCode(ZipCode zip) is:

      ..... // get ZipCode RemoteHome interface
      zipCodeRemote.create(pk, description, cityPK);
      catch (DuplicateKeyException ex)
      throw BackEndException("Primary Key already present");
      catch (CreateException ex)
      throw BackEndException("Unique constraint violeted");

      Unfortunately, when a unique constraint violation condition occurs
      CreateException is never caught (i.e. never thrown) while
      JBoss throw a TransactionRollback.

      Any idea how to solve this problem?