2 Replies Latest reply on Apr 10, 2010 8:00 AM by rodrigo.uchoa

    Customizing generated classes?

    rodrigo.uchoa

      Hi guys,

       

      I have and odd requirement and I was hoping someone could point me to the right direction.

       

      We are willing to use Envers in one of our projects, but we have a weird obstacle to overcome. Our current architecture demands that all JPA entities extend a particular class, called BaseEntity.

      If the entity is not a BaseEntity, it does not get flushed by hibernate. That means, it's never saved in the DB.

       

      That's our problem. Since envers generated classes do not extend our dearly beloved BaseEntity, we're not getting any audited data saved in the database. They are not being flushed.

       

      So, if I have an "User" entity annotated with @Audited, I know that somehow envers create a "clone" of this entity called "User_AUD". What I need is make this generated "User_AUD" class extend our 'BaseEntity'.

       

      Any clues?

       

      ps: Unfortunately, changing our architecture is not a possibility for now.

        • 1. Re: Customizing generated classes?
          adamw

          Hello,

           

          the entities generated by Envers are not based on classes, but on regular java maps, so it's not possible that they extend any other class. Maybe you could add a special case to your framework which enables flushing entities in the MAP entity mode (normally the entity mode is POJO), or if the entity name ends with _AUD?

           

          Adam

          • 2. Re: Customizing generated classes?
            rodrigo.uchoa

            Adam,

             

            I see. I'm afraid we're gonna have to patch our architecture code . Thanks for your quick reply and nice work on  the framework, it works great.