This patch is for hibernate3 plugin;
I have made a new configuration implementation called
JPAEnversComponentConfiguration (jpaenversconfiguration) that allow the
generation of ddl with envers.
Envers is a recent project that allow developers to audit entity beans. It
will be part of hibernate 3.5 as a module.
I have also made a test case based on existent test cases.
I hope that this patch will be integrated in a future release of the plugin
:)
--
Romain LAMARCHE
Fixe : 04 26 07 73 50
Mail : [email protected]
April Web Access Factory
29 rue Maurice Flandin
69444 LYON Cedex 03
http://www.april-waf.com
--
Romain LAMARCHE
Fixe : 04 26 07 73 50
Mail : [email protected]
April Web Access Factory
29 rue Maurice Flandin
69444 LYON Cedex 03
http://www.april-waf.com
Index: hibernate3-maven-plugin/src/test/java/org/codehaus/mojo/hibernate3/plugin/Hbm2DDLMojoTest.java
===================================================================
--- hibernate3-maven-plugin/src/test/java/org/codehaus/mojo/hibernate3/plugin/Hbm2DDLMojoTest.java (révision 9990)
+++ hibernate3-maven-plugin/src/test/java/org/codehaus/mojo/hibernate3/plugin/Hbm2DDLMojoTest.java (copie de travail)
@@ -38,4 +38,13 @@
assertTrue( "can't find target/hibernate3/sql-jpa/schema.sql",
checkExists( "target/hibernate3/sql-jpa/schema.sql" ) );
}
+
+ public void testJpaEnversMojoExecution()
+ throws Exception
+ {
+ deleteDirectory( "target/hibernate3/sql-jpa-envers" );
+ getHibernateMojo( "hbm2ddl", "jpaenversconfiguration" ).execute();
+ assertTrue( "can't find target/hibernate3/sql-jpa-envers/schema.sql",
+ checkExists( "target/hibernate3/sql-jpa-envers/schema.sql" ) );
+ }
}
Index: hibernate3-maven-plugin/src/test/java/org/codehaus/mojo/hibernate3/plugin/AbstractHibernate3MojoTestCase.java
===================================================================
--- hibernate3-maven-plugin/src/test/java/org/codehaus/mojo/hibernate3/plugin/AbstractHibernate3MojoTestCase.java (révision 9990)
+++ hibernate3-maven-plugin/src/test/java/org/codehaus/mojo/hibernate3/plugin/AbstractHibernate3MojoTestCase.java (copie de travail)
@@ -24,7 +24,12 @@
protected HibernateExporterMojo getHibernateMojo( String goal, String implementation )
throws Exception
{
- copyFileToDirectory( "target/test-classes/jpaconfiguration/META-INF/persistence.xml",
+ String dir = "jpaconfiguration";
+ if ("jpaenversconfiguration".equals(implementation))
+ {
+ dir = implementation;
+ }
+ copyFileToDirectory( "target/test-classes/" + dir + "/META-INF/persistence.xml",
"target/test-classes/META-INF" );
String path = "target/test-classes/" + implementation + "/" + goal + "-config.xml";
Index: hibernate3-maven-plugin/src/test/resources/jpaenversconfiguration/META-INF/persistence.xml
===================================================================
--- hibernate3-maven-plugin/src/test/resources/jpaenversconfiguration/META-INF/persistence.xml (révision 0)
+++ hibernate3-maven-plugin/src/test/resources/jpaenversconfiguration/META-INF/persistence.xml (révision 0)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- example of reference to a cfg.xml file -->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
+ version="1.0">
+ <persistence-unit name="ejb3test" transaction-type="RESOURCE_LOCAL">
+ <provider>org.hibernate.ejb.HibernatePersistence</provider>
+ <class>jpaenversconfiguration.PersonAudited</class>
+ <exclude-unlisted-classes>true</exclude-unlisted-classes>
+ <properties>
+ <property name="show_sql" value="true"/>
+ <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
+ </properties>
+ </persistence-unit>
+</persistence>
\ No newline at end of file
Index: hibernate3-maven-plugin/src/test/resources/jpaenversconfiguration/hbm2ddl-config.xml
===================================================================
--- hibernate3-maven-plugin/src/test/resources/jpaenversconfiguration/hbm2ddl-config.xml (révision 0)
+++ hibernate3-maven-plugin/src/test/resources/jpaenversconfiguration/hbm2ddl-config.xml (révision 0)
@@ -0,0 +1,24 @@
+<project>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>hibernate3-maven-plugin</artifactId>
+ <configuration>
+ <components>
+ <component>
+ <name>hbm2ddl</name>
+ <outputDirectory>target/hibernate3/sql-jpa-envers</outputDirectory>
+ <implementation>jpaenversconfiguration</implementation>
+ </component>
+ </components>
+ <componentProperties>
+ <persistenceunit>ejb3test</persistenceunit>
+ <export>false</export>
+ <outputfilename>schema.sql</outputfilename>
+ </componentProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Index: hibernate3-maven-plugin/pom.xml
===================================================================
--- hibernate3-maven-plugin/pom.xml (révision 9990)
+++ hibernate3-maven-plugin/pom.xml (copie de travail)
@@ -65,6 +65,12 @@
<artifactId>plexus-utils</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.jboss.envers</groupId>
+ <artifactId>jboss-envers</artifactId>
+ <version>1.2.1.GA-hibernate-3.3</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
Index: maven-hibernate3-components/maven-hibernate3-jdk15/src/main/java/org/codehaus/mojo/hibernate3/configuration/JPAEnversComponentConfiguration.java
===================================================================
--- maven-hibernate3-components/maven-hibernate3-jdk15/src/main/java/org/codehaus/mojo/hibernate3/configuration/JPAEnversComponentConfiguration.java (révision 0)
+++ maven-hibernate3-components/maven-hibernate3-jdk15/src/main/java/org/codehaus/mojo/hibernate3/configuration/JPAEnversComponentConfiguration.java (révision 0)
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2009 rlamarche.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * under the License.
+ */
+package org.codehaus.mojo.hibernate3.configuration;
+
+import org.hibernate.cfg.Configuration;
+import org.hibernate.envers.configuration.AuditConfiguration;
+
+/**
+ *
+ * @author rlamarche
+ */
+public class JPAEnversComponentConfiguration extends JPAComponentConfiguration {
+
+ @Override
+ public String getName() {
+ return "jpaenversconfiguration";
+ }
+
+ @Override
+ protected Configuration createConfiguration() {
+ Configuration configuration = super.createConfiguration();
+ AuditConfiguration.getFor(configuration);
+
+ return configuration;
+ }
+}
Index: maven-hibernate3-components/maven-hibernate3-jdk15/src/main/resources/META-INF/plexus/components.xml
===================================================================
--- maven-hibernate3-components/maven-hibernate3-jdk15/src/main/resources/META-INF/plexus/components.xml (révision 9990)
+++ maven-hibernate3-components/maven-hibernate3-jdk15/src/main/resources/META-INF/plexus/components.xml (copie de travail)
@@ -13,5 +13,11 @@
<implementation>org.codehaus.mojo.hibernate3.configuration.JPAComponentConfiguration</implementation>
</component>
+ <component>
+ <role>org.codehaus.mojo.hibernate3.configuration.ComponentConfiguration</role>
+ <role-hint>jpaenversconfiguration</role-hint>
+ <implementation>org.codehaus.mojo.hibernate3.configuration.JPAEnversComponentConfiguration</implementation>
+ </component>
+
</components>
</component-set>
Index: maven-hibernate3-components/maven-hibernate3-jdk15/pom.xml
===================================================================
--- maven-hibernate3-components/maven-hibernate3-jdk15/pom.xml (révision 9990)
+++ maven-hibernate3-components/maven-hibernate3-jdk15/pom.xml (copie de travail)
@@ -54,6 +54,11 @@
<artifactId>javassist</artifactId>
<version>3.4.GA</version>
</dependency>
+ <dependency>
+ <groupId>org.jboss.envers</groupId>
+ <artifactId>jboss-envers</artifactId>
+ <version>1.2.1.GA-hibernate-3.3</version>
+ </dependency>
</dependencies>
<build>
<plugins>
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email