1 Reply Latest reply on Mar 1, 2013 12:49 PM by Adam Warski

    Hibernate Envers Generation of DDL script with ant. AUD tables not generated

    spooker Newbie

      I have managed to generate the script with the following ant.

      The problem is that the generated script does not contain the AUDIT tables. Any clues what may be wrong with my configuration? Could this be a jar related bug?

      I am not using a hibernate.properties

       

      <target name="schemaexport"

                  description="Exports a generated schema to DB and file">

              <taskdef name="hibernatetool"

                       classname="org.hibernate.tool.ant.EnversHibernateToolTask"

                       classpathref="master-classpath"/>

       

              <hibernatetool destdir=".">

                  <classpath>

                      <fileset  dir="${lib.dir}" includes="**/*.jar"/>

                      <fileset  dir="${ejb-project.dir}/build" includes="**/*.jar"/>

                      <fileset  dir="${client-project.dir}/dist" includes="**/*.jar"/>

       

                  </classpath>

                  <jpaconfiguration persistenceunit="TestAppPU" />

                  <hbm2ddl

                          drop="false"

                          create="true"

                          export="false"

                          outputfilename="versioning-ddl.sql"

                          delimiter=";"

                          format="true"/>

              </hibernatetool>

          </target>

       

       

      In my classpath I use the following jars. (Some of them are irrelevant)

      commons-dbutils-1.5.jar

      commons-io-2.4.jar

      commons-lang3-3.1.jar

      commons-logging-1.1.1.jar

      dom4j-1.6.1.jar

      freemarker-2.3.18.jar

      gson-2.2.2.jar

      hibernate-commons-annotations-4.0.1.Final.jar

      hibernate-core-4.0.1.Final.jar

      hibernate-entitymanager-4.0.1.Final.jar

      hibernate-envers-4.0.1.Final.jar

      hibernate-jpa-2.0-api-1.0.1.Final.jar

      hibernate-tools-4.0.0-CR1.jar

      jasperreports-fonts-4.7.0.jar

      javassist-3.15.0-GA.jar

      jboss-logging-3.1.0.GA.jar

      jboss-transaction-api_1.1_spec-1.0.0.Final.jar

      joda-time-2.1.jar

      jython-2.5.3.jar

      opencsv-2.3.jar

      poi-3.7-20101029.jar

      postgresql-9.1-901.jdbc4.jar

      slf4j-api-1.6.2.jar

      slf4j-simple-1.6.2.jar

       

      I had to add the following properties to persistence.xml

       

              <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>

              <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/>

              <property name="javax.persistence.jdbc.url" value="jdbc:postgresql://ip goes here:port goes here/schema goes here"/>

              <property name="javax.persistence.jdbc.user" value="postgres"/>

              <property name="javax.persistence.jdbc.password" value="password"/>

       

      Ant log

       

      Executing Hibernate Tool with a JPA Configuration

      1. task: hbm2ddl (Generates database schema)

      Φεβ 20, 2013 6:33:35 ΜΜ org.hibernate.annotations.common.Version <clinit>

      INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}

      Φεβ 20, 2013 6:33:35 ΜΜ org.hibernate.Version logVersion

      INFO: HHH000412: Hibernate Core {4.0.1.Final}

      Φεβ 20, 2013 6:33:35 ΜΜ org.hibernate.cfg.Environment <clinit>

      INFO: HHH000206: hibernate.properties not found  (Is this important ???)

      Φεβ 20, 2013 6:33:35 ΜΜ org.hibernate.cfg.Environment buildBytecodeProvider

      INFO: HHH000021: Bytecode provider name : javassist

      Φεβ 20, 2013 6:33:36 ΜΜ org.hibernate.tool.Version <clinit>

      INFO: Hibernate Tools 4.0.0

      Φεβ 20, 2013 6:33:36 ΜΜ org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure

      INFO: HHH000402: Using Hibernate built-in connection pool (not for production use!)

      Φεβ 20, 2013 6:33:37 ΜΜ org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure

      INFO: HHH000115: Hibernate connection pool size: 20

      Φεβ 20, 2013 6:33:37 ΜΜ org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure

      INFO: HHH000006: Autocommit mode: true

      Φεβ 20, 2013 6:33:37 ΜΜ org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure

      INFO: HHH000401: using driver [org.postgresql.Driver] at URL [jdbc:postgresql://ip hidden:port hidden/schema hidder]

      Φεβ 20, 2013 6:33:37 ΜΜ org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure

      INFO: HHH000046: Connection properties: {user=postgres, password=****, autocommit=true, release_mode=auto}

      Φεβ 20, 2013 6:33:37 ΜΜ org.hibernate.dialect.Dialect <init>

      INFO: HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect

      Φεβ 20, 2013 6:33:37 ΜΜ org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation

      INFO: HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException

      Φεβ 20, 2013 6:33:37 ΜΜ org.hibernate.tool.hbm2ddl.SchemaExport execute

      INFO: HHH000227: Running hbm2ddl schema export

          create table public.a (

              id int4 not null,

              a1 varchar(255),

              age int4,

              tversion int4,

              primary key (id)

          );

       

          create table public.b (

              id int4 not null,

              b1 varchar(255),

              tversion int4,

              a int4 not null,

              primary key (id),

              unique (b1, a)

          );

       

          alter table public.b

              add constraint FK62B5EADE01

              foreign key (a)

              references public.a;

      Φεβ 20, 2013 6:33:37 ΜΜ org.hibernate.tool.hbm2ddl.SchemaExport execute

      INFO: HHH000230: Schema export complete

      Ant build completed with 28 warnings in 13s at 20/2/2013 6:33 μμ