Author: adamw
Date: 2010-01-07 09:13:51 -0500 (Thu, 07 Jan 2010)
New Revision: 18429
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/AbstractAllAuditedTest.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/AuditedImplementor.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/NonAuditedImplementor.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/SimpleInterface.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/joined/
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/joined/JoinedAllAuditedTest.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/joined/joinedAllAuditedMappings.hbm.xml
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/subclass/
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/subclass/SubclassAllAuditedTest.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/subclass/subclassAllAuditedMappings.hbm.xml
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/union/
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/union/UnionAllAuditedTest.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/union/unionAllAuditedMappings.hbm.xml
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/AbstractPropertiesAuditedTest.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/AuditedImplementor.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/NonAuditedImplementor.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/SimpleInterface.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/joined/
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/joined/JoinedPropertiesAuditedTest.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/joined/joinedPropertiesAuditedMappings.hbm.xml
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/subclass/
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/subclass/SubclassPropertiesAuditedTest.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/subclass/subclassPropertiesAuditedMappings.hbm.xml
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/union/
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/union/UnionPropertiesAuditedTest.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/union/unionPropertiesAuditedMappings.hbm.xml
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/AbstractPropertiesAudited2Test.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/AuditedImplementor.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/NonAuditedImplementor.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/SimpleInterface.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/joined/
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/joined/JoinedPropertiesAudited2Test.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/joined/joinedPropertiesAudited2Mappings.hbm.xml
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/subclass/
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/subclass/SubclassPropertiesAudited2Test.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/subclass/subclassPropertiesAudited2Mappings.hbm.xml
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/union/
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/union/UnionPropertiesAudited2Test.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/union/unionPropertiesAudited2Mappings.hbm.xml
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/superclass/auditedAtSuperclassLevel/
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/superclass/auditedAtSuperclassLevel/MappedSubclassing2.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/superclass/auditedAtSuperclassLevel/SubclassEntity2.java
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/superclass/auditedAtSuperclassLevel/SuperclassOfEntity2.java
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/reader/AuditedPropertiesReader.java
core/trunk/envers/src/test/resources/testng.xml
Log:
HHH-4063:
- applying patch from Hern?\195?\161n Chanfreau - thanks!
- fixing metadata reading for interfaces
- tests when entities are interfaces
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/reader/AuditedPropertiesReader.java
===================================================================
---
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/reader/AuditedPropertiesReader.java 2010-01-07
13:56:47 UTC (rev 18428)
+++
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/reader/AuditedPropertiesReader.java 2010-01-07
14:13:51 UTC (rev 18429)
@@ -81,7 +81,7 @@
private void addPropertiesFromClass(XClass clazz) {
XClass superclazz = clazz.getSuperclass();
- if (!"java.lang.Object".equals(superclazz.getName())) {
+ if (!clazz.isInterface() &&
!"java.lang.Object".equals(superclazz.getName())) {
addPropertiesFromClass(superclazz);
}
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/AbstractAllAuditedTest.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/AbstractAllAuditedTest.java
(rev 0)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/AbstractAllAuditedTest.java 2010-01-07
14:13:51 UTC (rev 18429)
@@ -0,0 +1,122 @@
+package org.hibernate.envers.test.integration.interfaces.hbm.allAudited;
+
+import javax.persistence.EntityManager;
+
+import org.hibernate.envers.exception.NotAuditedException;
+import org.hibernate.envers.test.AbstractEntityTest;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+import org.testng.Assert;
+
+import java.util.Arrays;
+
+/**
+ * @author Hern�n Chanfreau
+ * @author Adam Warski (adam at warski dot org)
+ */
+public abstract class AbstractAllAuditedTest extends AbstractEntityTest {
+
+ private long ai_id;
+ private long nai_id;
+
+ @BeforeClass(dependsOnMethods = "init")
+ public void initData() {
+ EntityManager em = getEntityManager();
+
+ AuditedImplementor ai = new AuditedImplementor();
+ ai.setData("La data");
+ ai.setAuditedImplementorData("audited implementor data");
+
+ NonAuditedImplementor nai = new NonAuditedImplementor();
+ nai.setData("info");
+ nai.setNonAuditedImplementorData("sttring");
+
+ // Revision 1
+ em.getTransaction().begin();
+
+ em.persist(ai);
+
+ em.persist(nai);
+
+ em.getTransaction().commit();
+
+ // Revision 2
+ em.getTransaction().begin();
+
+ ai = em.find(AuditedImplementor.class, ai.getId());
+ nai = em.find(NonAuditedImplementor.class, nai.getId());
+
+ ai.setData("La data 2");
+ ai.setAuditedImplementorData("audited implementor data 2");
+
+ nai.setData("info 2");
+ nai.setNonAuditedImplementorData("sttring 2");
+
+ em.getTransaction().commit();
+
+ //
+
+ ai_id = ai.getId();
+ nai_id = nai.getId();
+ }
+
+ @Test
+ public void testRevisions() {
+ Assert.assertEquals(getAuditReader().getRevisions(AuditedImplementor.class,
ai_id), Arrays.asList(1, 2));
+ }
+
+ @Test
+ public void testRetrieveAudited() {
+ // levanto las versiones actuales
+ AuditedImplementor ai = getEntityManager().find(AuditedImplementor.class, ai_id);
+ assert ai != null;
+ SimpleInterface si = getEntityManager().find(SimpleInterface.class, ai_id);
+ assert si != null;
+
+ // levanto las de la revisi�n 1, ninguna debe ser null
+ AuditedImplementor ai_rev1 = getAuditReader().find(AuditedImplementor.class, ai_id,
1);
+ assert ai_rev1 != null;
+ SimpleInterface si_rev1 = getAuditReader().find(SimpleInterface.class, ai_id, 1);
+ assert si_rev1 != null;
+
+ AuditedImplementor ai_rev2 = getAuditReader().find(AuditedImplementor.class,
ai_id, 2);
+ assert ai_rev2 != null;
+ SimpleInterface si_rev2 = getAuditReader().find(SimpleInterface.class, ai_id, 2);
+ assert si_rev2 != null;
+
+ // data de las actuales no debe ser null
+ Assert.assertEquals(ai.getData(), "La data 2");
+ Assert.assertEquals(si.getData(), "La data 2");
+ // la data de las revisiones no debe ser null
+ Assert.assertEquals(ai_rev1.getData(), "La data");
+ Assert.assertEquals(si_rev1.getData(), "La data");
+
+ Assert.assertEquals(ai_rev2.getData(), "La data 2");
+ Assert.assertEquals(si_rev2.getData(), "La data 2");
+ }
+
+ @Test
+ public void testRetrieveNonAudited() {
+ // levanto las versiones actuales
+ NonAuditedImplementor nai = getEntityManager().find(NonAuditedImplementor.class,
nai_id);
+ assert nai != null;
+ SimpleInterface si = getEntityManager().find(SimpleInterface.class, nai_id);
+ assert si != null;
+
+ assert si.getData().equals(nai.getData());
+
+ try {
+ // levanto la revision
+ getAuditReader().find(NonAuditedImplementor.class, nai_id, 1);
+ assert false;
+ } catch (Exception e) {
+ // no es auditable!!!
+ assert (e instanceof NotAuditedException);
+ }
+
+ // levanto la revision que no es auditable pero con la interfaz, el resultado debe
ser null
+ SimpleInterface si_rev1 = getAuditReader().find(SimpleInterface.class, nai_id, 1);
+ assert si_rev1 == null;
+
+ }
+}
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/AuditedImplementor.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/AuditedImplementor.java
(rev 0)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/AuditedImplementor.java 2010-01-07
14:13:51 UTC (rev 18429)
@@ -0,0 +1,47 @@
+package org.hibernate.envers.test.integration.interfaces.hbm.allAudited;
+
+import org.hibernate.envers.Audited;
+
+/**
+ * @author Hern�n Chanfreau
+ *
+ */
+@Audited
+public class AuditedImplementor implements SimpleInterface {
+
+ private long id;
+
+ private String data;
+
+ private String auditedImplementorData;
+
+
+ protected AuditedImplementor() {
+
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getAuditedImplementorData() {
+ return auditedImplementorData;
+ }
+
+ public void setAuditedImplementorData(String implementorData) {
+ this.auditedImplementorData = implementorData;
+ }
+
+}
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/NonAuditedImplementor.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/NonAuditedImplementor.java
(rev 0)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/NonAuditedImplementor.java 2010-01-07
14:13:51 UTC (rev 18429)
@@ -0,0 +1,45 @@
+package org.hibernate.envers.test.integration.interfaces.hbm.allAudited;
+
+
+/**
+ * @author Hern�n Chanfreau
+ *
+ */
+public class NonAuditedImplementor implements SimpleInterface {
+
+ private long id;
+
+ private String data;
+
+ private String nonAuditedImplementorData;
+
+
+ protected NonAuditedImplementor() {
+
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getNonAuditedImplementorData() {
+ return nonAuditedImplementorData;
+ }
+
+ public void setNonAuditedImplementorData(String implementorData) {
+ this.nonAuditedImplementorData = implementorData;
+ }
+
+}
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/SimpleInterface.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/SimpleInterface.java
(rev 0)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/SimpleInterface.java 2010-01-07
14:13:51 UTC (rev 18429)
@@ -0,0 +1,20 @@
+package org.hibernate.envers.test.integration.interfaces.hbm.allAudited;
+
+import org.hibernate.envers.Audited;
+
+/**
+ * @author Hern�n Chanfreau
+ *
+ */
+@Audited
+public interface SimpleInterface {
+
+ long getId();
+
+ void setId(long id);
+
+ String getData();
+
+ void setData(String data);
+
+}
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/joined/JoinedAllAuditedTest.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/joined/JoinedAllAuditedTest.java
(rev 0)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/joined/JoinedAllAuditedTest.java 2010-01-07
14:13:51 UTC (rev 18429)
@@ -0,0 +1,43 @@
+package org.hibernate.envers.test.integration.interfaces.hbm.allAudited.joined;
+
+import java.io.File;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.hibernate.ejb.Ejb3Configuration;
+import
org.hibernate.envers.test.integration.interfaces.hbm.allAudited.AbstractAllAuditedTest;
+import org.testng.annotations.Test;
+
+/**
+ * @author Hern�n Chanfreau
+ *
+ */
+public class JoinedAllAuditedTest extends AbstractAllAuditedTest {
+
+ public void configure(Ejb3Configuration cfg) {
+ try {
+ URL url =
Thread.currentThread().getContextClassLoader().getResource("org/hibernate/envers/test/integration/interfaces/hbm/allAudited/joined/joinedAllAuditedMappings.hbm.xml");
+ cfg.addFile(new File(url.toURI()));
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ @Override
+ public void testRetrieveAudited() {
+ super.testRetrieveAudited();
+ }
+
+ @Test
+ @Override
+ public void testRetrieveNonAudited() {
+ super.testRetrieveNonAudited();
+ }
+
+ @Test
+ @Override
+ public void testRevisions() {
+ super.testRevisions();
+ }
+}
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/joined/joinedAllAuditedMappings.hbm.xml
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/joined/joinedAllAuditedMappings.hbm.xml
(rev 0)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/joined/joinedAllAuditedMappings.hbm.xml 2010-01-07
14:13:51 UTC (rev 18429)
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="WINDOWS-1251"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping>
+
+ <class
+ name="org.hibernate.envers.test.integration.interfaces.hbm.allAudited.SimpleInterface"
+ table="INTERFACE" abstract="true" >
+
+ <id name="id" column="ID" type="long">
+ <generator class="increment" />
+ </id>
+
+ <property name="data" column="DATA" />
+
+ </class>
+
+ <joined-subclass
+ name="org.hibernate.envers.test.integration.interfaces.hbm.allAudited.AuditedImplementor"
+ extends="org.hibernate.envers.test.integration.interfaces.hbm.allAudited.SimpleInterface"
+ table="AUDITED_IMPLEMENTOR" >
+
+ <key column="ID"/>
+
+ <property name="auditedImplementorData"
column="IMPLEMENTOR_DATA" />
+
+ </joined-subclass>
+
+ <joined-subclass
+ name="org.hibernate.envers.test.integration.interfaces.hbm.allAudited.NonAuditedImplementor"
+ extends="org.hibernate.envers.test.integration.interfaces.hbm.allAudited.SimpleInterface"
+ table="NON_AUDITED_IMPLEMENTOR" >
+
+ <key column="ID"/>
+
+ <property name="nonAuditedImplementorData"
column="NON_IMPLEMENTOR_DATA" />
+
+ </joined-subclass>
+
+</hibernate-mapping>
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/subclass/SubclassAllAuditedTest.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/subclass/SubclassAllAuditedTest.java
(rev 0)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/subclass/SubclassAllAuditedTest.java 2010-01-07
14:13:51 UTC (rev 18429)
@@ -0,0 +1,44 @@
+package org.hibernate.envers.test.integration.interfaces.hbm.allAudited.subclass;
+
+import java.io.File;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.hibernate.ejb.Ejb3Configuration;
+import
org.hibernate.envers.test.integration.interfaces.hbm.allAudited.AbstractAllAuditedTest;
+import org.testng.annotations.Test;
+
+/**
+ * @author Hern�n Chanfreau
+ *
+ */
+public class SubclassAllAuditedTest extends AbstractAllAuditedTest {
+
+ public void configure(Ejb3Configuration cfg) {
+ try {
+ URL url =
Thread.currentThread().getContextClassLoader().getResource("org/hibernate/envers/test/integration/interfaces/hbm/allAudited/subclass/subclassAllAuditedMappings.hbm.xml");
+ cfg.addFile(new File(url.toURI()));
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ @Override
+ public void testRetrieveAudited() {
+ super.testRetrieveAudited();
+ }
+
+ @Test
+ @Override
+ public void testRetrieveNonAudited() {
+ super.testRetrieveNonAudited();
+ }
+
+ @Test
+ @Override
+ public void testRevisions() {
+ super.testRevisions();
+ }
+
+}
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/subclass/subclassAllAuditedMappings.hbm.xml
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/subclass/subclassAllAuditedMappings.hbm.xml
(rev 0)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/subclass/subclassAllAuditedMappings.hbm.xml 2010-01-07
14:13:51 UTC (rev 18429)
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="WINDOWS-1251"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping>
+
+ <class
+ name="org.hibernate.envers.test.integration.interfaces.hbm.allAudited.SimpleInterface"
+ table="SIMPLES_interface"
discriminator-value="SIMPLE_INTERFACE">
+
+ <id name="id" column="ID" type="long">
+ <generator class="native" />
+ </id>
+
+ <discriminator column="DISCRIMINATOR" />
+
+ <property name="data" column="DATA" />
+
+ </class>
+
+ <subclass
+ name="org.hibernate.envers.test.integration.interfaces.hbm.allAudited.AuditedImplementor"
+ extends="org.hibernate.envers.test.integration.interfaces.hbm.allAudited.SimpleInterface"
+ discriminator-value="AUDITED_IMPLEMENTOR" >
+
+ <property name="auditedImplementorData"
column="IMPLEMENTOR_DATA" />
+
+ </subclass>
+
+ <subclass
+ name="org.hibernate.envers.test.integration.interfaces.hbm.allAudited.NonAuditedImplementor"
+ extends="org.hibernate.envers.test.integration.interfaces.hbm.allAudited.SimpleInterface"
+ discriminator-value="NON_AUDITED_IMPLEMENTOR" >
+
+ <property name="nonAuditedImplementorData"
column="NON_IMPLEMENTOR_DATA" />
+
+ </subclass>
+
+
+
+</hibernate-mapping>
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/union/UnionAllAuditedTest.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/union/UnionAllAuditedTest.java
(rev 0)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/union/UnionAllAuditedTest.java 2010-01-07
14:13:51 UTC (rev 18429)
@@ -0,0 +1,43 @@
+package org.hibernate.envers.test.integration.interfaces.hbm.allAudited.union;
+
+import java.io.File;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.hibernate.ejb.Ejb3Configuration;
+import
org.hibernate.envers.test.integration.interfaces.hbm.allAudited.AbstractAllAuditedTest;
+import org.testng.annotations.Test;
+
+/**
+ * @author Hern�n Chanfreau
+ *
+ */
+public class UnionAllAuditedTest extends AbstractAllAuditedTest {
+
+ public void configure(Ejb3Configuration cfg) {
+ try {
+ URL url =
Thread.currentThread().getContextClassLoader().getResource("org/hibernate/envers/test/integration/interfaces/hbm/allAudited/union/unionAllAuditedMappings.hbm.xml");
+ cfg.addFile(new File(url.toURI()));
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ @Override
+ public void testRetrieveAudited() {
+ super.testRetrieveAudited();
+ }
+
+ @Test
+ @Override
+ public void testRetrieveNonAudited() {
+ super.testRetrieveNonAudited();
+ }
+
+ @Test
+ @Override
+ public void testRevisions() {
+ super.testRevisions();
+ }
+}
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/union/unionAllAuditedMappings.hbm.xml
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/union/unionAllAuditedMappings.hbm.xml
(rev 0)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/allAudited/union/unionAllAuditedMappings.hbm.xml 2010-01-07
14:13:51 UTC (rev 18429)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="WINDOWS-1251"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping>
+
+ <class
+ name="org.hibernate.envers.test.integration.interfaces.hbm.allAudited.SimpleInterface"
+ abstract="true" >
+
+ <id name="id" column="ID" type="long">
+ <generator class="increment" />
+ </id>
+
+ <property name="data" column="DATA" />
+
+ </class>
+
+ <union-subclass
+ name="org.hibernate.envers.test.integration.interfaces.hbm.allAudited.AuditedImplementor"
+ extends="org.hibernate.envers.test.integration.interfaces.hbm.allAudited.SimpleInterface"
+ table="AUDITED_IMPLEMENTOR" >
+
+ <property name="auditedImplementorData"
column="IMPLEMENTOR_DATA" />
+
+ </union-subclass>
+
+ <union-subclass
+ name="org.hibernate.envers.test.integration.interfaces.hbm.allAudited.NonAuditedImplementor"
+ extends="org.hibernate.envers.test.integration.interfaces.hbm.allAudited.SimpleInterface"
+ table="NON_AUDITED_IMPLEMENTOR" >
+
+ <property name="nonAuditedImplementorData"
column="NON_IMPLEMENTOR_DATA" />
+
+ </union-subclass>
+
+</hibernate-mapping>
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/AbstractPropertiesAuditedTest.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/AbstractPropertiesAuditedTest.java
(rev 0)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/AbstractPropertiesAuditedTest.java 2010-01-07
14:13:51 UTC (rev 18429)
@@ -0,0 +1,109 @@
+package org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited;
+
+import javax.persistence.EntityManager;
+
+import org.hibernate.envers.exception.NotAuditedException;
+import org.hibernate.envers.test.AbstractEntityTest;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @author Hern�n Chanfreau
+ *
+ */
+
+public abstract class AbstractPropertiesAuditedTest extends AbstractEntityTest {
+
+ private long ai_id;
+ private long nai_id;
+
+ private static int NUMERITO = 555;
+
+ @BeforeClass(dependsOnMethods = "init")
+ public void initData() {
+ EntityManager em = getEntityManager();
+
+ AuditedImplementor ai = new AuditedImplementor();
+ ai.setData("La data");
+ ai.setAuditedImplementorData("audited implementor data");
+ ai.setNumerito(NUMERITO);
+
+ NonAuditedImplementor nai = new NonAuditedImplementor();
+ nai.setData("info");
+ nai.setNonAuditedImplementorData("sttring");
+ nai.setNumerito(NUMERITO);
+
+ // Revision 1
+ em.getTransaction().begin();
+
+ em.persist(ai);
+
+ em.persist(nai);
+
+ em.getTransaction().commit();
+
+ // Revision 2
+
+ // Revision 3
+
+ ai_id = ai.getId();
+ nai_id = nai.getId();
+ }
+
+ @Test
+ public void testRetrieveAudited() {
+ // levanto las versiones actuales
+ AuditedImplementor ai = getEntityManager().find(
+ AuditedImplementor.class, ai_id);
+ assert ai != null;
+ SimpleInterface si = getEntityManager().find(SimpleInterface.class,
+ ai_id);
+ assert si != null;
+
+ // levanto las de la revisi�n 1, ninguna debe ser null
+ AuditedImplementor ai_rev1 = getAuditReader().find(
+ AuditedImplementor.class, ai_id, 1);
+ assert ai_rev1 != null;
+ SimpleInterface si_rev1 = getAuditReader().find(SimpleInterface.class,
+ ai_id, 1);
+ assert si_rev1 != null;
+
+ // data de las actuales no debe ser null
+ assert ai.getData() != null;
+ assert si.getData() != null;
+ // data de las revisiones No est� auditada
+ assert ai_rev1.getData() == null;
+ assert si_rev1.getData() == null;
+ // numerito de las revisiones est� auditada, debe ser igual a NUMERITO
+ assert ai_rev1.getNumerito() == NUMERITO;
+ assert si_rev1.getNumerito() == NUMERITO;
+ }
+
+ @Test
+ public void testRetrieveNonAudited() {
+ // levanto las versiones actuales
+ NonAuditedImplementor nai = getEntityManager().find(
+ NonAuditedImplementor.class, nai_id);
+ assert nai != null;
+ SimpleInterface si = getEntityManager().find(SimpleInterface.class,
+ nai_id);
+ assert si != null;
+
+ assert si.getData().equals(nai.getData());
+
+ try {
+ // levanto la revision
+ getAuditReader().find(NonAuditedImplementor.class, nai_id, 1);
+ assert false;
+ } catch (Exception e) {
+ // no es auditable!!!
+ assert (e instanceof NotAuditedException);
+ }
+
+ // levanto la revision que no es auditable pero con la interfaz, el
+ // resultado debe ser null
+ SimpleInterface si_rev1 = getAuditReader().find(SimpleInterface.class,
+ nai_id, 1);
+ assert si_rev1 == null;
+ }
+}
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/AuditedImplementor.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/AuditedImplementor.java
(rev 0)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/AuditedImplementor.java 2010-01-07
14:13:51 UTC (rev 18429)
@@ -0,0 +1,58 @@
+package org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited;
+
+import org.hibernate.envers.Audited;
+
+/**
+ * @author Hern�n Chanfreau
+ *
+ */
+
+@Audited
+public class AuditedImplementor implements SimpleInterface {
+
+ private long id;
+
+ private String data;
+
+ private String auditedImplementorData;
+
+ private int numerito;
+
+
+ protected AuditedImplementor() {
+
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getAuditedImplementorData() {
+ return auditedImplementorData;
+ }
+
+ public void setAuditedImplementorData(String implementorData) {
+ this.auditedImplementorData = implementorData;
+ }
+
+ public int getNumerito() {
+ return numerito;
+ }
+
+ public void setNumerito(int numerito) {
+ this.numerito = numerito;
+ }
+
+}
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/NonAuditedImplementor.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/NonAuditedImplementor.java
(rev 0)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/NonAuditedImplementor.java 2010-01-07
14:13:51 UTC (rev 18429)
@@ -0,0 +1,54 @@
+package org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited;
+
+/**
+ * @author Hern�n Chanfreau
+ *
+ */
+
+public class NonAuditedImplementor implements SimpleInterface {
+
+ private long id;
+
+ private String data;
+
+ private String nonAuditedImplementorData;
+
+ private int numerito;
+
+
+ protected NonAuditedImplementor() {
+
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getNonAuditedImplementorData() {
+ return nonAuditedImplementorData;
+ }
+
+ public void setNonAuditedImplementorData(String implementorData) {
+ this.nonAuditedImplementorData = implementorData;
+ }
+
+ public int getNumerito() {
+ return numerito;
+ }
+
+ public void setNumerito(int numerito) {
+ this.numerito = numerito;
+ }
+}
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/SimpleInterface.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/SimpleInterface.java
(rev 0)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/SimpleInterface.java 2010-01-07
14:13:51 UTC (rev 18429)
@@ -0,0 +1,25 @@
+package org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited;
+
+import org.hibernate.envers.Audited;
+
+/**
+ * @author Hern�n Chanfreau
+ *
+ */
+
+public interface SimpleInterface {
+
+ long getId();
+
+ void setId(long id);
+
+ String getData();
+
+ void setData(String data);
+
+ @Audited
+ int getNumerito();
+
+ void setNumerito(int num);
+
+}
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/joined/JoinedPropertiesAuditedTest.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/joined/JoinedPropertiesAuditedTest.java
(rev 0)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/joined/JoinedPropertiesAuditedTest.java 2010-01-07
14:13:51 UTC (rev 18429)
@@ -0,0 +1,31 @@
+package org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.joined;
+
+import java.io.File;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.hibernate.ejb.Ejb3Configuration;
+import
org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.AbstractPropertiesAuditedTest;
+import org.testng.annotations.Test;
+
+/**
+ * @author Hern�n Chanfreau
+ *
+ */
+
+public class JoinedPropertiesAuditedTest extends AbstractPropertiesAuditedTest {
+
+ public void configure(Ejb3Configuration cfg) {
+ try {
+ URL url =
Thread.currentThread().getContextClassLoader().getResource("org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/joined/joinedPropertiesAuditedMappings.hbm.xml");
+ cfg.addFile(new File(url.toURI()));
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testRetrieveAudited() {
+ super.testRetrieveAudited();
+ }
+}
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/joined/joinedPropertiesAuditedMappings.hbm.xml
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/joined/joinedPropertiesAuditedMappings.hbm.xml
(rev 0)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/joined/joinedPropertiesAuditedMappings.hbm.xml 2010-01-07
14:13:51 UTC (rev 18429)
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="WINDOWS-1251"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping>
+
+ <class
+ name="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.SimpleInterface"
+ table="INTERFACE" abstract="true" >
+
+ <id name="id" column="ID" type="long">
+ <generator class="increment" />
+ </id>
+
+ <property name="data" column="DATA" />
+
+ <property name="numerito" column="NUMERITO" />
+
+ </class>
+
+ <joined-subclass
+ name="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.AuditedImplementor"
+ extends="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.SimpleInterface"
+ table="AUDITED_IMPLEMENTOR" >
+
+ <key column="ID"/>
+
+ <property name="auditedImplementorData"
column="IMPLEMENTOR_DATA" />
+
+ </joined-subclass>
+
+ <joined-subclass
+ name="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.NonAuditedImplementor"
+ extends="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.SimpleInterface"
+ table="NON_AUDITED_IMPLEMENTOR" >
+
+ <key column="ID"/>
+
+ <property name="nonAuditedImplementorData"
column="NON_IMPLEMENTOR_DATA" />
+
+ </joined-subclass>
+
+</hibernate-mapping>
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/subclass/SubclassPropertiesAuditedTest.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/subclass/SubclassPropertiesAuditedTest.java
(rev 0)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/subclass/SubclassPropertiesAuditedTest.java 2010-01-07
14:13:51 UTC (rev 18429)
@@ -0,0 +1,33 @@
+package org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.subclass;
+
+import java.io.File;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.hibernate.ejb.Ejb3Configuration;
+import
org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.AbstractPropertiesAuditedTest;
+import org.testng.annotations.Test;
+
+/**
+ * @author Hern�n Chanfreau
+ *
+ */
+
+public class SubclassPropertiesAuditedTest extends AbstractPropertiesAuditedTest {
+
+ public void configure(Ejb3Configuration cfg) {
+ try {
+ URL url =
Thread.currentThread().getContextClassLoader().getResource("org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/subclass/subclassPropertiesAuditedMappings.hbm.xml");
+ cfg.addFile(new File(url.toURI()));
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ @Test
+ public void testRetrieveAudited() {
+ super.testRetrieveAudited();
+ }
+
+}
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/subclass/subclassPropertiesAuditedMappings.hbm.xml
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/subclass/subclassPropertiesAuditedMappings.hbm.xml
(rev 0)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/subclass/subclassPropertiesAuditedMappings.hbm.xml 2010-01-07
14:13:51 UTC (rev 18429)
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="WINDOWS-1251"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping>
+
+ <class
+ name="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.SimpleInterface"
+ table="SIMPLES_interface"
discriminator-value="SIMPLE_INTERFACE">
+
+ <id name="id" column="ID" type="long">
+ <generator class="native" />
+ </id>
+
+ <discriminator column="DISCRIMINATOR" />
+
+ <property name="data" column="DATA" />
+
+ <property name="numerito" column="NUMERITO" />
+
+ </class>
+
+ <subclass
+ name="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.AuditedImplementor"
+ extends="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.SimpleInterface"
+ discriminator-value="AUDITED_IMPLEMENTOR" >
+
+ <property name="auditedImplementorData"
column="IMPLEMENTOR_DATA" />
+
+ </subclass>
+
+ <subclass
+ name="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.NonAuditedImplementor"
+ extends="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.SimpleInterface"
+ discriminator-value="NON_AUDITED_IMPLEMENTOR" >
+
+ <property name="nonAuditedImplementorData"
column="NON_IMPLEMENTOR_DATA" />
+
+ </subclass>
+
+</hibernate-mapping>
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/union/UnionPropertiesAuditedTest.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/union/UnionPropertiesAuditedTest.java
(rev 0)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/union/UnionPropertiesAuditedTest.java 2010-01-07
14:13:51 UTC (rev 18429)
@@ -0,0 +1,31 @@
+package org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.union;
+
+import java.io.File;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.hibernate.ejb.Ejb3Configuration;
+import
org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.AbstractPropertiesAuditedTest;
+import org.testng.annotations.Test;
+
+/**
+ * @author Hern�n Chanfreau
+ *
+ */
+
+public class UnionPropertiesAuditedTest extends AbstractPropertiesAuditedTest {
+
+ public void configure(Ejb3Configuration cfg) {
+ try {
+ URL url =
Thread.currentThread().getContextClassLoader().getResource("org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/union/unionPropertiesAuditedMappings.hbm.xml");
+ cfg.addFile(new File(url.toURI()));
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testRetrieveAudited() {
+ super.testRetrieveAudited();
+ }
+}
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/union/unionPropertiesAuditedMappings.hbm.xml
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/union/unionPropertiesAuditedMappings.hbm.xml
(rev 0)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited/union/unionPropertiesAuditedMappings.hbm.xml 2010-01-07
14:13:51 UTC (rev 18429)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="WINDOWS-1251"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping>
+
+ <class
+ name="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.SimpleInterface"
+ abstract="true" >
+
+ <id name="id" column="ID" type="long">
+ <generator class="increment" />
+ </id>
+
+ <property name="data" column="DATA" />
+
+ <property name="numerito" column="NUMERITO" />
+
+ </class>
+
+ <union-subclass
+ name="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.AuditedImplementor"
+ extends="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.SimpleInterface"
+ table="AUDITED_IMPLEMENTOR" >
+
+ <property name="auditedImplementorData"
column="IMPLEMENTOR_DATA" />
+
+ </union-subclass>
+
+ <union-subclass
+ name="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.NonAuditedImplementor"
+ extends="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.SimpleInterface"
+ table="NON_AUDITED_IMPLEMENTOR" >
+
+ <property name="nonAuditedImplementorData"
column="NON_IMPLEMENTOR_DATA" />
+
+ </union-subclass>
+
+</hibernate-mapping>
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/AbstractPropertiesAudited2Test.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/AbstractPropertiesAudited2Test.java
(rev 0)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/AbstractPropertiesAudited2Test.java 2010-01-07
14:13:51 UTC (rev 18429)
@@ -0,0 +1,109 @@
+package org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2;
+
+import javax.persistence.EntityManager;
+
+import org.hibernate.envers.exception.NotAuditedException;
+import org.hibernate.envers.test.AbstractEntityTest;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @author Hern�n Chanfreau
+ *
+ */
+
+public abstract class AbstractPropertiesAudited2Test extends AbstractEntityTest {
+
+ private long ai_id;
+ private long nai_id;
+
+ private static int NUMERITO = 555;
+
+ @BeforeClass(dependsOnMethods = "init")
+ public void initData() {
+ EntityManager em = getEntityManager();
+
+ AuditedImplementor ai = new AuditedImplementor();
+ ai.setData("La data");
+ ai.setAuditedImplementorData("audited implementor data");
+ ai.setNumerito(NUMERITO);
+
+ NonAuditedImplementor nai = new NonAuditedImplementor();
+ nai.setData("info");
+ nai.setNonAuditedImplementorData("sttring");
+ nai.setNumerito(NUMERITO);
+
+ // Revision 1
+ em.getTransaction().begin();
+
+ em.persist(ai);
+
+ em.persist(nai);
+
+ em.getTransaction().commit();
+
+ // Revision 2
+
+ // Revision 3
+
+ ai_id = ai.getId();
+ nai_id = nai.getId();
+ }
+
+ @Test
+ public void testRetrieveAudited() {
+ // levanto las versiones actuales
+ AuditedImplementor ai = getEntityManager().find(
+ AuditedImplementor.class, ai_id);
+ assert ai != null;
+ SimpleInterface si = getEntityManager().find(SimpleInterface.class,
+ ai_id);
+ assert si != null;
+
+ // levanto las de la revisi�n 1, ninguna debe ser null
+ AuditedImplementor ai_rev1 = getAuditReader().find(
+ AuditedImplementor.class, ai_id, 1);
+ assert ai_rev1 != null;
+ SimpleInterface si_rev1 = getAuditReader().find(SimpleInterface.class,
+ ai_id, 1);
+ assert si_rev1 != null;
+
+ // data de las actuales no debe ser null
+ assert ai.getData() != null;
+ assert si.getData() != null;
+ // data de las revisiones est� auditada
+ assert ai_rev1.getData() != null;
+ assert si_rev1.getData() != null;
+ // numerito de las revisiones est� auditada, debe ser igual a NUMERITO
+ assert ai_rev1.getNumerito() == NUMERITO;
+ assert si_rev1.getNumerito() == NUMERITO;
+ }
+
+ @Test
+ public void testRetrieveNonAudited() {
+ // levanto las versiones actuales
+ NonAuditedImplementor nai = getEntityManager().find(
+ NonAuditedImplementor.class, nai_id);
+ assert nai != null;
+ SimpleInterface si = getEntityManager().find(SimpleInterface.class,
+ nai_id);
+ assert si != null;
+
+ assert si.getData().equals(nai.getData());
+
+ try {
+ // levanto la revision
+ getAuditReader().find(NonAuditedImplementor.class, nai_id, 1);
+ assert false;
+ } catch (Exception e) {
+ // no es auditable!!!
+ assert (e instanceof NotAuditedException);
+ }
+
+ // levanto la revision que no es auditable pero con la interfaz, el
+ // resultado debe ser null
+ SimpleInterface si_rev1 = getAuditReader().find(SimpleInterface.class,
+ nai_id, 1);
+ assert si_rev1 == null;
+ }
+}
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/AuditedImplementor.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/AuditedImplementor.java
(rev 0)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/AuditedImplementor.java 2010-01-07
14:13:51 UTC (rev 18429)
@@ -0,0 +1,58 @@
+package org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2;
+
+import org.hibernate.envers.Audited;
+
+/**
+ * @author Hern�n Chanfreau
+ *
+ */
+
+@Audited
+public class AuditedImplementor implements SimpleInterface {
+
+ private long id;
+
+ private String data;
+
+ private String auditedImplementorData;
+
+ private int numerito;
+
+
+ protected AuditedImplementor() {
+
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getAuditedImplementorData() {
+ return auditedImplementorData;
+ }
+
+ public void setAuditedImplementorData(String implementorData) {
+ this.auditedImplementorData = implementorData;
+ }
+
+ public int getNumerito() {
+ return numerito;
+ }
+
+ public void setNumerito(int numerito) {
+ this.numerito = numerito;
+ }
+
+}
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/NonAuditedImplementor.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/NonAuditedImplementor.java
(rev 0)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/NonAuditedImplementor.java 2010-01-07
14:13:51 UTC (rev 18429)
@@ -0,0 +1,54 @@
+package org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2;
+
+/**
+ * @author Hern�n Chanfreau
+ *
+ */
+
+public class NonAuditedImplementor implements SimpleInterface {
+
+ private long id;
+
+ private String data;
+
+ private String nonAuditedImplementorData;
+
+ private int numerito;
+
+
+ protected NonAuditedImplementor() {
+
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ public String getNonAuditedImplementorData() {
+ return nonAuditedImplementorData;
+ }
+
+ public void setNonAuditedImplementorData(String implementorData) {
+ this.nonAuditedImplementorData = implementorData;
+ }
+
+ public int getNumerito() {
+ return numerito;
+ }
+
+ public void setNumerito(int numerito) {
+ this.numerito = numerito;
+ }
+}
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/SimpleInterface.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/SimpleInterface.java
(rev 0)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/SimpleInterface.java 2010-01-07
14:13:51 UTC (rev 18429)
@@ -0,0 +1,26 @@
+package org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2;
+
+import org.hibernate.envers.Audited;
+
+/**
+ * @author Hern�n Chanfreau
+ *
+ */
+
+public interface SimpleInterface {
+
+ long getId();
+
+ void setId(long id);
+
+ @Audited
+ String getData();
+
+ void setData(String data);
+
+ @Audited
+ int getNumerito();
+
+ void setNumerito(int num);
+
+}
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/joined/JoinedPropertiesAudited2Test.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/joined/JoinedPropertiesAudited2Test.java
(rev 0)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/joined/JoinedPropertiesAudited2Test.java 2010-01-07
14:13:51 UTC (rev 18429)
@@ -0,0 +1,31 @@
+package org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.joined;
+
+import java.io.File;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.hibernate.ejb.Ejb3Configuration;
+import
org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.AbstractPropertiesAudited2Test;
+import org.testng.annotations.Test;
+
+/**
+ * @author Hern�n Chanfreau
+ *
+ */
+
+public class JoinedPropertiesAudited2Test extends AbstractPropertiesAudited2Test {
+
+ public void configure(Ejb3Configuration cfg) {
+ try {
+ URL url =
Thread.currentThread().getContextClassLoader().getResource("org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/joined/joinedPropertiesAudited2Mappings.hbm.xml");
+ cfg.addFile(new File(url.toURI()));
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testRetrieveAudited() {
+ super.testRetrieveAudited();
+ }
+}
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/joined/joinedPropertiesAudited2Mappings.hbm.xml
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/joined/joinedPropertiesAudited2Mappings.hbm.xml
(rev 0)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/joined/joinedPropertiesAudited2Mappings.hbm.xml 2010-01-07
14:13:51 UTC (rev 18429)
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="WINDOWS-1251"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping>
+
+ <class
+ name="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.SimpleInterface"
+ table="INTERFACE" abstract="true" >
+
+ <id name="id" column="ID" type="long">
+ <generator class="increment" />
+ </id>
+
+ <property name="data" column="DATA" />
+
+ </class>
+
+ <joined-subclass
+ name="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.AuditedImplementor"
+ extends="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.SimpleInterface"
+ table="AUDITED_IMPLEMENTOR" >
+
+ <key column="ID"/>
+
+ <property name="auditedImplementorData"
column="IMPLEMENTOR_DATA" />
+
+ <property name="numerito" column="NUMERITO" />
+
+ </joined-subclass>
+
+ <joined-subclass
+ name="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.NonAuditedImplementor"
+ extends="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.SimpleInterface"
+ table="NON_AUDITED_IMPLEMENTOR" >
+
+ <key column="ID"/>
+
+ <property name="nonAuditedImplementorData"
column="NON_IMPLEMENTOR_DATA" />
+
+ <property name="numerito" column="NUMERITO" />
+
+ </joined-subclass>
+
+</hibernate-mapping>
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/subclass/SubclassPropertiesAudited2Test.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/subclass/SubclassPropertiesAudited2Test.java
(rev 0)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/subclass/SubclassPropertiesAudited2Test.java 2010-01-07
14:13:51 UTC (rev 18429)
@@ -0,0 +1,33 @@
+package
org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.subclass;
+
+import java.io.File;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.hibernate.ejb.Ejb3Configuration;
+import
org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.AbstractPropertiesAudited2Test;
+import org.testng.annotations.Test;
+
+/**
+ * @author Hern�n Chanfreau
+ *
+ */
+
+public class SubclassPropertiesAudited2Test extends AbstractPropertiesAudited2Test {
+
+ public void configure(Ejb3Configuration cfg) {
+ try {
+ URL url =
Thread.currentThread().getContextClassLoader().getResource("org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/subclass/subclassPropertiesAudited2Mappings.hbm.xml");
+ cfg.addFile(new File(url.toURI()));
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ @Test
+ public void testRetrieveAudited() {
+ super.testRetrieveAudited();
+ }
+
+}
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/subclass/subclassPropertiesAudited2Mappings.hbm.xml
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/subclass/subclassPropertiesAudited2Mappings.hbm.xml
(rev 0)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/subclass/subclassPropertiesAudited2Mappings.hbm.xml 2010-01-07
14:13:51 UTC (rev 18429)
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="WINDOWS-1251"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping>
+
+ <class
+ name="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.SimpleInterface"
+ table="SIMPLES_interface"
discriminator-value="SIMPLE_INTERFACE">
+
+ <id name="id" column="ID" type="long">
+ <generator class="native" />
+ </id>
+
+ <discriminator column="DISCRIMINATOR" />
+
+ <property name="data" column="DATA" />
+
+ </class>
+
+ <subclass
+ name="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.AuditedImplementor"
+ extends="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.SimpleInterface"
+ discriminator-value="AUDITED_IMPLEMENTOR" >
+
+ <property name="auditedImplementorData"
column="IMPLEMENTOR_DATA" />
+
+ <property name="numerito" column="NUMERITO" />
+
+ </subclass>
+
+ <subclass
+ name="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.NonAuditedImplementor"
+ extends="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.SimpleInterface"
+ discriminator-value="NON_AUDITED_IMPLEMENTOR" >
+
+ <property name="nonAuditedImplementorData"
column="NON_IMPLEMENTOR_DATA" />
+
+ <property name="numerito" column="NUMERITO" />
+
+ </subclass>
+
+</hibernate-mapping>
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/union/UnionPropertiesAudited2Test.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/union/UnionPropertiesAudited2Test.java
(rev 0)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/union/UnionPropertiesAudited2Test.java 2010-01-07
14:13:51 UTC (rev 18429)
@@ -0,0 +1,31 @@
+package org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.union;
+
+import java.io.File;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.hibernate.ejb.Ejb3Configuration;
+import
org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.AbstractPropertiesAudited2Test;
+import org.testng.annotations.Test;
+
+/**
+ * @author Hern�n Chanfreau
+ *
+ */
+
+public class UnionPropertiesAudited2Test extends AbstractPropertiesAudited2Test {
+
+ public void configure(Ejb3Configuration cfg) {
+ try {
+ URL url =
Thread.currentThread().getContextClassLoader().getResource("org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/union/unionPropertiesAudited2Mappings.hbm.xml");
+ cfg.addFile(new File(url.toURI()));
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testRetrieveAudited() {
+ super.testRetrieveAudited();
+ }
+}
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/union/unionPropertiesAudited2Mappings.hbm.xml
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/union/unionPropertiesAudited2Mappings.hbm.xml
(rev 0)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/interfaces/hbm/propertiesAudited2/union/unionPropertiesAudited2Mappings.hbm.xml 2010-01-07
14:13:51 UTC (rev 18429)
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="WINDOWS-1251"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping>
+
+ <class
+ name="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.SimpleInterface"
+ abstract="true" >
+
+ <id name="id" column="ID" type="long">
+ <generator class="increment" />
+ </id>
+
+ <property name="data" column="DATA" />
+
+ </class>
+
+ <union-subclass
+ name="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.AuditedImplementor"
+ extends="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.SimpleInterface"
+ table="AUDITED_IMPLEMENTOR" >
+
+ <property name="auditedImplementorData"
column="IMPLEMENTOR_DATA" />
+
+ <property name="numerito" column="NUMERITO" />
+
+ </union-subclass>
+
+ <union-subclass
+ name="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.NonAuditedImplementor"
+ extends="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.SimpleInterface"
+ table="NON_AUDITED_IMPLEMENTOR" >
+
+ <property name="nonAuditedImplementorData"
column="NON_IMPLEMENTOR_DATA" />
+
+ <property name="numerito" column="NUMERITO" />
+
+ </union-subclass>
+
+</hibernate-mapping>
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/superclass/auditedAtSuperclassLevel/MappedSubclassing2.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/superclass/auditedAtSuperclassLevel/MappedSubclassing2.java
(rev 0)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/superclass/auditedAtSuperclassLevel/MappedSubclassing2.java 2010-01-07
14:13:51 UTC (rev 18429)
@@ -0,0 +1,84 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.envers.test.integration.superclass.auditedAtSuperclassLevel;
+
+import java.util.Arrays;
+
+import javax.persistence.EntityManager;
+
+import org.hibernate.ejb.Ejb3Configuration;
+import org.hibernate.envers.test.AbstractEntityTest;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ *
+ * @author Hern�n Chanfreau
+ *
+ * Same test from package
+ * org.hibernate.envers.test.integration.superclass changing the Audited
+ * annotation in MappedSuperclass from property str to class level
+ */
+public class MappedSubclassing2 extends AbstractEntityTest {
+ private Integer id1;
+
+ public void configure(Ejb3Configuration cfg) {
+ cfg.addAnnotatedClass(SubclassEntity2.class);
+ }
+
+ @BeforeClass(dependsOnMethods = "init")
+ public void initData() {
+ // Revision 1
+ EntityManager em = getEntityManager();
+ em.getTransaction().begin();
+ SubclassEntity2 se1 = new SubclassEntity2("x");
+ em.persist(se1);
+ id1 = se1.getId();
+ em.getTransaction().commit();
+
+ // Revision 2
+ em.getTransaction().begin();
+ se1 = em.find(SubclassEntity2.class, id1);
+ se1.setStr("y");
+ em.getTransaction().commit();
+ }
+
+ @Test
+ public void testRevisionsCounts() {
+ assert Arrays.asList(1, 2).equals(
+ getAuditReader().getRevisions(SubclassEntity2.class, id1));
+ }
+
+ @Test
+ public void testHistoryOfId1() {
+ SubclassEntity2 ver1 = new SubclassEntity2(id1, "x");
+ SubclassEntity2 ver2 = new SubclassEntity2(id1, "y");
+
+ assert getAuditReader().find(SubclassEntity2.class, id1, 1)
+ .equals(ver1);
+ assert getAuditReader().find(SubclassEntity2.class, id1, 2)
+ .equals(ver2);
+ }
+}
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/superclass/auditedAtSuperclassLevel/SubclassEntity2.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/superclass/auditedAtSuperclassLevel/SubclassEntity2.java
(rev 0)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/superclass/auditedAtSuperclassLevel/SubclassEntity2.java 2010-01-07
14:13:51 UTC (rev 18429)
@@ -0,0 +1,87 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.envers.test.integration.superclass.auditedAtSuperclassLevel;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ *
+ * @author Hern�n Chanfreau
+ *
+ * Same class from package
+ * org.hibernate.envers.test.integration.superclass changing the
+ * superclass to MappedSuperclass2
+ */
+@Entity
+public class SubclassEntity2 extends SuperclassOfEntity2 {
+ @Id
+ @GeneratedValue
+ private Integer id;
+
+ public SubclassEntity2() {
+ }
+
+ public SubclassEntity2(Integer id, String str) {
+ super(str);
+ this.id = id;
+ }
+
+ public SubclassEntity2(String str) {
+ super(str);
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (!(o instanceof SubclassEntity2))
+ return false;
+ if (!super.equals(o))
+ return false;
+
+ SubclassEntity2 that = (SubclassEntity2) o;
+
+ //noinspection RedundantIfStatement
+ if (id != null ? !id.equals(that.id) : that.id != null)
+ return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ int result = super.hashCode();
+ result = 31 * result + (id != null ? id.hashCode() : 0);
+ return result;
+ }
+}
Added:
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/superclass/auditedAtSuperclassLevel/SuperclassOfEntity2.java
===================================================================
---
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/superclass/auditedAtSuperclassLevel/SuperclassOfEntity2.java
(rev 0)
+++
core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/superclass/auditedAtSuperclassLevel/SuperclassOfEntity2.java 2010-01-07
14:13:51 UTC (rev 18429)
@@ -0,0 +1,78 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.envers.test.integration.superclass.auditedAtSuperclassLevel;
+
+import javax.persistence.MappedSuperclass;
+
+import org.hibernate.envers.Audited;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ *
+ * @author Hern�n Chanfreau
+ *
+ * Same class from package
+ * org.hibernate.envers.test.integration.superclass changing the Audited
+ * annotation from property str to class level
+ */
+@MappedSuperclass
+@Audited
+public class SuperclassOfEntity2 {
+
+ private String str;
+
+ public SuperclassOfEntity2() {
+ }
+
+ public SuperclassOfEntity2(String str) {
+ this.str = str;
+ }
+
+ public String getStr() {
+ return str;
+ }
+
+ public void setStr(String str) {
+ this.str = str;
+ }
+
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (!(o instanceof SuperclassOfEntity2))
+ return false;
+
+ SuperclassOfEntity2 that = (SuperclassOfEntity2) o;
+
+ //noinspection RedundantIfStatement
+ if (str != null ? !str.equals(that.str) : that.str != null)
+ return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ return (str != null ? str.hashCode() : 0);
+ }
+}
Modified: core/trunk/envers/src/test/resources/testng.xml
===================================================================
--- core/trunk/envers/src/test/resources/testng.xml 2010-01-07 13:56:47 UTC (rev 18428)
+++ core/trunk/envers/src/test/resources/testng.xml 2010-01-07 14:13:51 UTC (rev 18429)
@@ -31,6 +31,15 @@
<package
name="org.hibernate.envers.test.integration.inheritance.tableperclass.relation"
/>
<package
name="org.hibernate.envers.test.integration.interfaces.components" />
<package
name="org.hibernate.envers.test.integration.interfaces.relation" />
+ <package
name="org.hibernate.envers.test.integration.interfaces.hbm.allAudited.subclass"
/>
+ <package
name="org.hibernate.envers.test.integration.interfaces.hbm.allAudited.joined"
/>
+ <package
name="org.hibernate.envers.test.integration.interfaces.hbm.allAudited.union"
/>
+ <package
name="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.subclass"
/>
+ <package
name="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.joined"
/>
+ <package
name="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited.union"
/>
+ <package
name="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.subclass"
/>
+ <package
name="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.joined"
/>
+ <package
name="org.hibernate.envers.test.integration.interfaces.hbm.propertiesAudited2.union"
/>
<package name="org.hibernate.envers.test.integration.manytomany"
/>
<package
name="org.hibernate.envers.test.integration.manytomany.biowned" />
<package
name="org.hibernate.envers.test.integration.manytomany.sametable" />