3 Replies Latest reply on Jan 8, 2009 4:20 PM by adamw

    Deleting an entity - Bug?

    kaizersh

      Hi,

      If I delete an entity, the values of the deleted entity should also get persisted in my audit table. However, it tries to enter a NULL value throwing an exception -

      Caused by: java.sql.BatchUpdateException: ORA-01400: cannot insert NULL into ("FW_DEV"."COM_CLIENT_M_AUD"."CLIENTTYPECD")

      at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:343)

      I had a look at the postDeleteMethod in AuditEventListener and it doesnt seem to do anything with the deletedState. It should be persisting this state in the Audit table.

      Please let me know if this is a bug or if I'm missing something.

      Thanks.

      Regards
      Kaizer

        • 1. Re: Deleting an entity - Bug?
          adamw

          Hello,

          when you delete an entity, only the id, revision number and revision type fields won't be null. All the rest will be. That's because a row in the audit tables contains the *new* data of the entity - and when you delete, there's no new data.

          The last data of the entity is of course not lost, you can find it in the last revision the entity was modified (or created)

          --
          Adam

          • 2. Re: Deleting an entity - Bug?
            kaizersh

            Hi,

            In our case, even our Audit Tables have Not Null constraints and we actually store the last data in the audit table. Is there some way I can achieve this with Envers? One way would be to override the postDelete method in my Listener class and change the DelWorkUnit accordingly.

            Thanks.

            Regards
            Kaizer

            • 3. Re: Deleting an entity - Bug?
              adamw

              Well, that's exactly the way to do it :)

              --
              Adam