2 Replies Latest reply on Jun 9, 2008 7:13 AM by adamw

    How to change the default table names and column names for O

    richardhan

      I see the issue has been addressed in the new version and we are trying to make Envers to work with Oracle. So far no lucky. Questions:

      1) For config solution, we do not use EntityManager, we use Spring 2.0 + Hibernate 3.0 for SE, how we can plug in the config info into either hibernate.cfg.xml or Spring xml? May we just put the config in a plain property file?

      2) If using @RevisionEntity, usually we setup the ID as a Long, in this situation, can you give us a example to use the @RevisionEntity to change the default table and fields names?

      Thanks.

      Richard

        • 1. Re: How to change the default table names and column names f
          adamw

          Hello,

          as for configuring Envers with Hibernate, it is enough to add the listeners to hibernate.cfg.xml:

          <session-factory>
           <event type="post-insert">
           <listener class="org.jboss.envers.event.VersionsEventListener" />
           </event>
           <event type="post-update">
           <listener class="org.jboss.envers.event.VersionsEventListener" />
           </event>
           <event type="post-delete">
           <listener class="org.jboss.envers.event.VersionsEventListener" />
           </event>
          </session-factory>
          


          As for the type of the revision number, currently is hard-coded to be int/Integer, but you're right that it should be changed (http://jira.jboss.org/jira/browse/ENVERS-12).

          If you have an entity annotated with @RevisionEntity, you change the table name and field names in the normal way, as with any other entity (so with @Table, @Column annotations). Is that what you asked about, or didn't I understand? :)

          ps The newest dev (http://www.jboss.org/envers/downloads/development) version of the library has a changed db schema, so it'd be better if you used this. This schema won't change until the 1.0 release.

          --
          Adam

          • 2. Re: How to change the default table names and column names f
            adamw

            Hello,

            the revision number can now be a long (the type of the field annotated with @RevisionNumber should be a long/Long). Also, all methods that previously accepted int revision, now accept Number revision, so you can pass either an int or a long.

            --
            Adam