# Envers inserting into existent database and table

**URL:** <https://discourse.hibernate.org/t/envers-inserting-into-existent-database-and-table/1543>\
**Category:** Hibernate ORM\
**Created:** [October 18, 2018, 7:25am UTC](https://discourse.hibernate.org/t/envers-inserting-into-existent-database-and-table/1543 "2018-10-18T07:25:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aleexalcaraz](https://avatars.discourse-cdn.com/v4/letter/a/d6d6ee/32.png) [@aleexalcaraz](https://discourse.hibernate.org/u/aleexalcaraz)\
**Post date:** [October 18, 2018, 7:25am UTC](https://discourse.hibernate.org/t/envers-inserting-into-existent-database-and-table/1543/1 "2018-10-18T07:25:45Z")

</div>

Hello, we are going to give envers a chance to be our auditing system.  
First we want to know if it’s possible to insert the audit info into a existent table. eg: We have a table that looks like this:  
Action | Field | New Value | Old Value |  
Somehow we want that envers automatically inserts like this. (Maybe over writting envers code or I don’t know )  
I think that is difficult. I am proposing to generate this information with the default way(create entity, entity\_AUD and REVINFO) then manipulate the data using queries, flags and more and finally inserting to the above table.  
What do you think we can do?  
Thanks

---

<div class="post-metadata">

**Author:** ![vlad](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/vlad/32/658_2.png) [@vlad](https://discourse.hibernate.org/u/vlad)\
**Post date:** [October 18, 2018, 8:04am UTC](https://discourse.hibernate.org/t/envers-inserting-into-existent-database-and-table/1543/2 "2018-10-18T08:04:07Z")

</div>

Envers has its own tables as explained in the [documentation](http://docs.jboss.org/hibernate/orm/5.3/userguide/html_single/Hibernate_User_Guide.html#envers).

I’m not sure to what extent you can customize Envers to write to those tables, but if you plan on using Envers, it’s more to migrate the old data to the new Envers format.

Maybe @Naros can provide you more info about customizing Envers.

---

<div class="post-metadata">

**Author:** ![aleexalcaraz](https://avatars.discourse-cdn.com/v4/letter/a/d6d6ee/32.png) [@aleexalcaraz](https://discourse.hibernate.org/u/aleexalcaraz)\
**Post date:** [October 18, 2018, 9:23am UTC](https://discourse.hibernate.org/t/envers-inserting-into-existent-database-and-table/1543/3 "2018-10-18T09:23:00Z")

</div>

> [@vlad](#):
>
> but if you plan on using Envers, it’s more to migrate the old data to the new Envers format.

I know this would be easier, thanks for the answer

---

<div class="post-metadata">

**Author:** ![aleexalcaraz](https://avatars.discourse-cdn.com/v4/letter/a/d6d6ee/32.png) [@aleexalcaraz](https://discourse.hibernate.org/u/aleexalcaraz)\
**Post date:** [October 23, 2018, 12:54pm UTC](https://discourse.hibernate.org/t/envers-inserting-into-existent-database-and-table/1543/4 "2018-10-23T12:54:41Z")

</div>

@Naros Do you think you can help with this?. Can envers be customized in this way?

---

<div class="post-metadata">

**Author:** ![Naros](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/naros/32/19_2.png) [@Naros](https://discourse.hibernate.org/u/Naros)\
**Post date:** [October 23, 2018, 1:11pm UTC](https://discourse.hibernate.org/t/envers-inserting-into-existent-database-and-table/1543/5 "2018-10-23T13:11:52Z")

</div>

There is no way to customize Envers such that it produces a schema like you described. A fair bit of that is all internal and explicitly not meant to be extendable because of how audit queries are generated and a number of core assumptions required to maintain the audit rows efficiently for all types of entity mappings.
