1 Reply Latest reply on Jul 17, 2008 8:21 AM by Adam Warski

    Versioned table schema generation

    faisal aziz Newbie

      Hey Guys I am trying to generate the schema for versioned tables, but I can not find the schema for the versioned table in the generated schema.

      I have a question though, about generating the versioned tables through the ant hibernate tools.

      I am using this script.

      <taskdef name="hibernatetool"
       classname="org.hibernate.tool.ant.EnversHibernateToolTask"
       classpathref="cp"/>
      
       <hibernatetool destdir="${tmp.dir}">
       <classpath>
       <path refid="java-dist-cp" />
       </classpath>
       <jpaconfiguration persistenceunit="myPU" />
       <hbm2ddl
       drop="false"
       create="true"
       export="false"
       outputfilename="versioning-ddl.sql"
       delimiter=";"
       format="true"/>
       </hibernatetool>
      


       <persistence-unit name="@db.persistenceunit@" transaction-type="RESOURCE_LOCAL">
       <!--<jta-data-source>java:/@db.datasource.jndi@</jta-data-source>-->
       <non-jta-data-source>java:@application.name@DS</non-jta-data-source>
       <properties>
       <property name="hibernate.dialect" value="@db.dialect@" />
       <property name="hibernate.cache.provider_class" value="org.hibernate.cache.EhCacheProvider" />
       <property name="hibernate.cache.use_query_cache" value="true" />
       <property name="hibernate.jdbc.batch_size" value="50" />
       <property name="hibernate.cache.provider_configuration_file_resource_path" value="ehcache.xml" />
       <property name="hibernate.use_second_level_cache" value="true" />
       <property name="hibernate.use_query_cache" value="true" />
       <property name="hibernate.connection.release_mode" value="auto" />
       <property name="hibernate.connection.autocommit" value="false" />
       <property name="hibernate.generate_statistics" value="true" />
      
       <property name="hibernate.ejb.event.post-insert"
       value="org.jboss.envers.event.VersionsEventListener" />
       <property name="hibernate.ejb.event.post-update"
       value="org.jboss.envers.event.VersionsEventListener" />
       <property name="hibernate.ejb.event.post-delete"
       value="org.jboss.envers.event.VersionsEventListener" />
       <property name="org.jboss.envers.versionsTableSuffix" value="_V" />
       <property name="org.jboss.envers.revisionFieldName" value="ver_rev" />
       </properties>
       </persistence-unit>
      



      @Entity
      @Table(name = "ROLE")
      @Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
      @Versioned
      public class Role implements Serializable {
       /** Id of the entity. */
       protected Integer id;
       /** Name of the role. */
       protected String name;
       /** Description of the role. */
       protected String description;
      
       @Id
       @GeneratedValue(strategy = GenerationType.AUTO)
       @Column(name = "RID")
       public Integer getId() {
       return id;
       }
      
       public void setId(Integer id) {
       this.id = id;
       }
      
       @Column(name = "NAME")
       public String getName() {
       return name;
       }
      
       public void setName(String name) {
       this.name = name;
       }
      
       @Column(name = "DESCRIPTION")
       public String getDescription() {
       return description;
       }
      
       public void setDescription(String description) {
       this.description = description;
       }
      }
      



      It generates the schema for all the entities except for the versioned entity.