[hibernate-commits] Hibernate SVN: r15566 - in core/trunk/envers/src: main/java/org/hibernate/envers/configuration/metadata and 8 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Sat Nov 15 10:23:25 EST 2008


Author: adamw
Date: 2008-11-15 10:23:25 -0500 (Sat, 15 Nov 2008)
New Revision: 15566

Added:
   core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditTableData.java
   core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/ChildAuditing.java
   core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/ParentAuditing.java
   core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/notownedrelation/
   core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/notownedrelation/NotOwnedBidirectional.java
   core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/
   core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/ChildAuditing.java
   core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/ChildEntity.java
   core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/ParentAuditing.java
   core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/ParentEntity.java
   core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/childrelation/
   core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/childrelation/ChildIngEntity.java
   core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/childrelation/ChildReferencing.java
   core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/childrelation/ParentNotIngEntity.java
   core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/childrelation/ReferencedEntity.java
   core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/notownedrelation/
   core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/notownedrelation/Address.java
   core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/notownedrelation/Contact.java
   core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/notownedrelation/NotOwnedBidirectional.java
   core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/notownedrelation/PersonalContact.java
   core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/relation/
   core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/relation/ChildIngEntity.java
   core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/relation/ParentIngEntity.java
   core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/relation/PolymorphicCollection.java
   core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/relation/ReferencedEntity.java
Removed:
   core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/ChildVersioning.java
   core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/ParentVersioning.java
   core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/inheritedrelation/
   core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/notownedrelation/InheritedBidirectional.java
Modified:
   core/trunk/envers/src/main/java/org/hibernate/envers/configuration/RevisionInfoConfiguration.java
   core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java
   core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/CollectionMetadataGenerator.java
   core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/EntityXmlMappingData.java
   core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/MetadataTools.java
   core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/notownedrelation/Address.java
   core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/notownedrelation/Contact.java
   core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/notownedrelation/PersonalContact.java
   core/trunk/envers/src/test/resources/testng.xml
Log:
HHH-3564: support for table-per-class inheritance strategy with tests

Modified: core/trunk/envers/src/main/java/org/hibernate/envers/configuration/RevisionInfoConfiguration.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/configuration/RevisionInfoConfiguration.java	2008-11-14 15:16:23 UTC (rev 15565)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/configuration/RevisionInfoConfiguration.java	2008-11-15 15:23:25 UTC (rev 15566)
@@ -32,6 +32,7 @@
 import org.hibernate.envers.*;
 import org.hibernate.envers.entities.PropertyData;
 import org.hibernate.envers.configuration.metadata.MetadataTools;
+import org.hibernate.envers.configuration.metadata.AuditTableData;
 import org.hibernate.envers.revisioninfo.DefaultRevisionInfoGenerator;
 import org.hibernate.envers.revisioninfo.RevisionInfoGenerator;
 import org.hibernate.envers.revisioninfo.RevisionInfoNumberReader;
@@ -68,7 +69,7 @@
     private Document generateDefaultRevisionInfoXmlMapping() {
         Document document = DocumentHelper.createDocument();
 
-        Element class_mapping = MetadataTools.createEntity(document, null, null, null, null, null);
+        Element class_mapping = MetadataTools.createEntity(document, new AuditTableData(null, null, null, null), null);
 
         class_mapping.addAttribute("name", revisionInfoEntityName);
         class_mapping.addAttribute("table", "REVINFO");

Modified: core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java	2008-11-14 15:16:23 UTC (rev 15565)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java	2008-11-15 15:23:25 UTC (rev 15566)
@@ -37,6 +37,7 @@
 import org.hibernate.envers.entities.mapper.MultiPropertyMapper;
 import org.hibernate.envers.entities.mapper.SubclassPropertyMapper;
 import org.hibernate.envers.tools.StringTools;
+import org.hibernate.envers.tools.Triple;
 
 import org.hibernate.MappingException;
 import org.hibernate.cfg.Configuration;
@@ -210,6 +211,47 @@
     }
 
     @SuppressWarnings({"unchecked"})
+    private Triple<Element, ExtendedPropertyMapper, String> generateMappingData(
+            PersistentClass pc, EntityXmlMappingData xmlMappingData, AuditTableData auditTableData,
+            IdMappingData idMapper) {
+        Element class_mapping = MetadataTools.createEntity(xmlMappingData.getMainXmlMapping(), auditTableData,
+                pc.getDiscriminatorValue());
+        ExtendedPropertyMapper propertyMapper = new MultiPropertyMapper();
+
+        // Checking if there is a discriminator column
+        if (pc.getDiscriminator() != null) {
+            Element discriminator_element = class_mapping.addElement("discriminator");
+            MetadataTools.addColumns(discriminator_element, pc.getDiscriminator().getColumnIterator());
+            discriminator_element.addAttribute("type", pc.getDiscriminator().getType().getName());
+        }
+
+        // Adding the id mapping
+        class_mapping.add((Element) idMapper.getXmlMapping().clone());
+
+        // Adding the "revision type" property
+        addRevisionType(class_mapping);
+
+        return Triple.make(class_mapping, propertyMapper, null);
+    }
+
+    private Triple<Element, ExtendedPropertyMapper, String> generateInheritanceMappingData(
+            PersistentClass pc, EntityXmlMappingData xmlMappingData, AuditTableData auditTableData,
+            String inheritanceMappingType) {
+        String extendsEntityName = verEntCfg.getAuditEntityName(pc.getSuperclass().getEntityName());
+        Element class_mapping = MetadataTools.createSubclassEntity(xmlMappingData.getMainXmlMapping(),
+                inheritanceMappingType, auditTableData, extendsEntityName, pc.getDiscriminatorValue());
+
+        // The id and revision type is already mapped in the parent
+
+        // Getting the property mapper of the parent - when mapping properties, they need to be included
+        String parentEntityName = pc.getSuperclass().getEntityName();
+        ExtendedPropertyMapper parentPropertyMapper = entitiesConfigurations.get(parentEntityName).getPropertyMapper();
+        ExtendedPropertyMapper propertyMapper = new SubclassPropertyMapper(new MultiPropertyMapper(), parentPropertyMapper);
+
+        return Triple.make(class_mapping, propertyMapper, parentEntityName);
+    }
+
+    @SuppressWarnings({"unchecked"})
     public void generateFirstPass(PersistentClass pc, PersistentClassAuditingData auditingData,
                                   EntityXmlMappingData xmlMappingData) {
         String schema = auditingData.getAuditTable().schema();
@@ -226,56 +268,47 @@
         String auditEntityName = verEntCfg.getAuditEntityName(entityName);
         String auditTableName = verEntCfg.getAuditTableName(entityName, pc.getTable().getName());
 
+        AuditTableData auditTableData = new AuditTableData(auditEntityName, auditTableName, schema, catalog);
+
         // Generating a mapping for the id
         IdMappingData idMapper = idMetadataGenerator.addId(pc);
 
-        Element class_mapping;
-        ExtendedPropertyMapper propertyMapper;
-
         InheritanceType inheritanceType = InheritanceType.get(pc);
-        String parentEntityName = null;
 
+        // These properties will be read from the mapping data
+        final Element class_mapping;
+        final ExtendedPropertyMapper propertyMapper;
+        final String parentEntityName;
+
+        final Triple<Element, ExtendedPropertyMapper, String> mappingData;
+
+        // Reading the mapping data depending on inheritance type (if any)
         switch (inheritanceType) {
             case NONE:
-                class_mapping = MetadataTools.createEntity(xmlMappingData.getMainXmlMapping(), auditEntityName, auditTableName,
-                        schema, catalog, pc.getDiscriminatorValue());
-                propertyMapper = new MultiPropertyMapper();
+                mappingData = generateMappingData(pc, xmlMappingData, auditTableData, idMapper);
+                break;
 
-                // Checking if there is a discriminator column
-                if (pc.getDiscriminator() != null) {
-                    Element discriminator_element = class_mapping.addElement("discriminator");
-                    MetadataTools.addColumns(discriminator_element, pc.getDiscriminator().getColumnIterator());
-                    discriminator_element.addAttribute("type", pc.getDiscriminator().getType().getName());
-                }
-
-                // Adding the id mapping
-                class_mapping.add((Element) idMapper.getXmlMapping().clone());
-
-                // Adding the "revision type" property
-                addRevisionType(class_mapping);
-
+            case SINGLE:
+                mappingData = generateInheritanceMappingData(pc, xmlMappingData, auditTableData, "subclass");
                 break;
-            case SINGLE:
-                String extendsEntityName = verEntCfg.getAuditEntityName(pc.getSuperclass().getEntityName());
-                class_mapping = MetadataTools.createSubclassEntity(xmlMappingData.getMainXmlMapping(), auditEntityName,
-                        auditTableName, schema, catalog, extendsEntityName, pc.getDiscriminatorValue());
 
-                // The id and revision type is already mapped in the parent
-
-                // Getting the property mapper of the parent - when mapping properties, they need to be included
-                parentEntityName = pc.getSuperclass().getEntityName();
-                ExtendedPropertyMapper parentPropertyMapper = entitiesConfigurations.get(parentEntityName).getPropertyMapper();
-                propertyMapper = new SubclassPropertyMapper(new MultiPropertyMapper(), parentPropertyMapper);
-
-                break;
             case JOINED:
                 throw new MappingException("Joined inheritance strategy not supported for auditing!");
+
             case TABLE_PER_CLASS:
-                throw new MappingException("Table-per-class inheritance strategy not supported for auditing!");
+                mappingData = generateInheritanceMappingData(pc, xmlMappingData, auditTableData, "union-subclass");
+                break;
+
             default:
                 throw new AssertionError("Impossible enum value.");
         }
 
+        class_mapping = mappingData.getFirst();
+        propertyMapper = mappingData.getSecond();
+        parentEntityName = mappingData.getThird();
+
+        xmlMappingData.setClassMapping(class_mapping);
+
         // Mapping unjoined properties
         addProperties(class_mapping, (Iterator<Property>) pc.getUnjoinedPropertyIterator(), propertyMapper,
                 auditingData, pc.getEntityName(), xmlMappingData,
@@ -299,10 +332,7 @@
         CompositeMapperBuilder propertyMapper = entitiesConfigurations.get(entityName).getPropertyMapper();
 
         // Mapping unjoined properties
-        Element parent = xmlMappingData.getMainXmlMapping().getRootElement().element("class");
-        if (parent == null) {
-            parent = xmlMappingData.getMainXmlMapping().getRootElement().element("subclass");
-        }
+        Element parent = xmlMappingData.getClassMapping();
 
         addProperties(parent, (Iterator<Property>) pc.getUnjoinedPropertyIterator(),
                 propertyMapper, auditingData, entityName, xmlMappingData, false);

Added: core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditTableData.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditTableData.java	                        (rev 0)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditTableData.java	2008-11-15 15:23:25 UTC (rev 15566)
@@ -0,0 +1,60 @@
+/*
+ * 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.configuration.metadata;
+
+/**
+ * Holds information necessary to create an audit table: its name, schema and catalog, as well as the audit
+ * entity name.
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class AuditTableData {
+    private final String auditEntityName;
+    private final String auditTableName;
+    private final String schema;
+    private final String catalog;
+
+    public AuditTableData(String auditEntityName, String auditTableName, String schema, String catalog) {
+        this.auditEntityName = auditEntityName;
+        this.auditTableName = auditTableName;
+        this.schema = schema;
+        this.catalog = catalog;
+    }
+
+    public String getAuditEntityName() {
+        return auditEntityName;
+    }
+
+    public String getAuditTableName() {
+        return auditTableName;
+    }
+
+    public String getSchema() {
+        return schema;
+    }
+
+    public String getCatalog() {
+        return catalog;
+    }
+}

Modified: core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/CollectionMetadataGenerator.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/CollectionMetadataGenerator.java	2008-11-14 15:16:23 UTC (rev 15565)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/CollectionMetadataGenerator.java	2008-11-15 15:23:25 UTC (rev 15566)
@@ -468,7 +468,7 @@
                 propertyValue.getCollectionTable().getCatalog() : persistentPropertyAuditingData.getJoinTable().catalog();
 
         Element middleEntityXml = MetadataTools.createEntity(xmlMappingData.newAdditionalMapping(),
-                auditMiddleEntityName, auditMiddleTableName, schema, catalog, null);
+                new AuditTableData(auditMiddleEntityName, auditMiddleTableName, schema, catalog), null);
         Element middleEntityXmlId = middleEntityXml.addElement("composite-id");
 
         middleEntityXmlId.addAttribute("name", mainGenerator.getVerEntCfg().getOriginalIdPropName());

Modified: core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/EntityXmlMappingData.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/EntityXmlMappingData.java	2008-11-14 15:16:23 UTC (rev 15565)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/EntityXmlMappingData.java	2008-11-15 15:23:25 UTC (rev 15566)
@@ -28,6 +28,7 @@
 
 import org.dom4j.Document;
 import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
 
 /**
  * @author Adam Warski (adam at warski dot org)
@@ -35,6 +36,11 @@
 public class EntityXmlMappingData {
     private Document mainXmlMapping;
     private List<Document> additionalXmlMappings;
+    /**
+     * The xml element that maps the class. The root can be one of the folowing elements:
+     * class, subclass, union-subclass, joined-subclass
+     */
+    private Element classMapping;
 
     public EntityXmlMappingData() {
         mainXmlMapping = DocumentHelper.createDocument();
@@ -55,4 +61,12 @@
 
         return additionalMapping;
     }
+
+    public Element getClassMapping() {
+        return classMapping;
+    }
+
+    public void setClassMapping(Element classMapping) {
+        this.classMapping = classMapping;
+    }
 }

Modified: core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/MetadataTools.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/MetadataTools.java	2008-11-14 15:16:23 UTC (rev 15565)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/MetadataTools.java	2008-11-15 15:23:25 UTC (rev 15566)
@@ -79,47 +79,43 @@
         return column_mapping;
     }
 
-    private static Element createEntityCommon(Document document, String type, String entityName,
-                                              String tableName, String schema, String catalog,
+    private static Element createEntityCommon(Document document, String type, AuditTableData auditTableData,
                                               String discriminatorValue) {
         Element hibernate_mapping = document.addElement("hibernate-mapping");
         hibernate_mapping.addAttribute("auto-import", "false");
 
         Element class_mapping = hibernate_mapping.addElement(type);
 
-        if (entityName != null) {
-            class_mapping.addAttribute("entity-name", entityName);
+        if (auditTableData.getAuditEntityName() != null) {
+            class_mapping.addAttribute("entity-name", auditTableData.getAuditEntityName());
         }
 
         if (discriminatorValue != null) {
             class_mapping.addAttribute("discriminator-value", discriminatorValue);
         }
 
-        if (!StringTools.isEmpty(tableName)) {
-            class_mapping.addAttribute("table", tableName);
+        if (!StringTools.isEmpty(auditTableData.getAuditTableName())) {
+            class_mapping.addAttribute("table", auditTableData.getAuditTableName());
         }
 
-        if (!StringTools.isEmpty(schema)) {
-            class_mapping.addAttribute("schema", schema);
+        if (!StringTools.isEmpty(auditTableData.getSchema())) {
+            class_mapping.addAttribute("schema", auditTableData.getSchema());
         }
 
-        if (!StringTools.isEmpty(catalog)) {
-            class_mapping.addAttribute("catalog", catalog);
+        if (!StringTools.isEmpty(auditTableData.getCatalog())) {
+            class_mapping.addAttribute("catalog", auditTableData.getCatalog());
         }
 
         return class_mapping;
     }
 
-    public static Element createEntity(Document document, String entityName, String tableName,
-                                       String schema, String catalog, String discriminatorValue) {
-        return createEntityCommon(document, "class", entityName, tableName, schema, catalog, discriminatorValue);
+    public static Element createEntity(Document document, AuditTableData auditTableData, String discriminatorValue) {
+        return createEntityCommon(document, "class", auditTableData, discriminatorValue);
     }
 
-    public static Element createSubclassEntity(Document document, String entityName, String tableName,
-                                               String schema, String catalog, String extendsEntityName,
-                                               String discriminatorValue) {
-        Element class_mapping = createEntityCommon(document, "subclass", entityName, tableName, schema, catalog,
-                discriminatorValue);
+    public static Element createSubclassEntity(Document document, String subclassType, AuditTableData auditTableData,
+                                               String extendsEntityName, String discriminatorValue) {
+        Element class_mapping = createEntityCommon(document, subclassType, auditTableData, discriminatorValue);
 
         class_mapping.addAttribute("extends", extendsEntityName);
 

Copied: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/ChildAuditing.java (from rev 15550, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/ChildVersioning.java)
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/ChildAuditing.java	                        (rev 0)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/ChildAuditing.java	2008-11-15 15:23:25 UTC (rev 15566)
@@ -0,0 +1,92 @@
+/*
+ * 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.inheritance.single;
+
+import java.util.Arrays;
+import javax.persistence.EntityManager;
+
+import org.hibernate.envers.test.AbstractEntityTest;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import org.hibernate.ejb.Ejb3Configuration;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class ChildAuditing extends AbstractEntityTest {
+    private Integer id1;
+
+    public void configure(Ejb3Configuration cfg) {
+        cfg.addAnnotatedClass(ChildEntity.class);
+        cfg.addAnnotatedClass(ParentEntity.class);
+    }
+
+    @BeforeClass(dependsOnMethods = "init")
+    public void initData() {
+        EntityManager em = getEntityManager();
+
+        // Rev 1
+        em.getTransaction().begin();
+        ChildEntity ce = new ChildEntity("x", 1l);
+        em.persist(ce);
+        id1 = ce.getId();
+        em.getTransaction().commit();
+
+        // Rev 2
+        em.getTransaction().begin();
+        ce = em.find(ChildEntity.class, id1);
+        ce.setData("y");
+        ce.setNumber(2l);
+        em.getTransaction().commit();
+    }
+
+    @Test
+    public void testRevisionsCounts() {
+        assert Arrays.asList(1, 2).equals(getAuditReader().getRevisions(ChildEntity.class, id1));
+    }
+
+    @Test
+    public void testHistoryOfChildId1() {
+        ChildEntity ver1 = new ChildEntity(id1, "x", 1l);
+        ChildEntity ver2 = new ChildEntity(id1, "y", 2l);
+
+        assert getAuditReader().find(ChildEntity.class, id1, 1).equals(ver1);
+        assert getAuditReader().find(ChildEntity.class, id1, 2).equals(ver2);
+
+        assert getAuditReader().find(ParentEntity.class, id1, 1).equals(ver1);
+        assert getAuditReader().find(ParentEntity.class, id1, 2).equals(ver2);
+    }
+
+    @Test
+    public void testPolymorphicQuery() {
+        ChildEntity childVer1 = new ChildEntity(id1, "x", 1l);
+
+        assert getAuditReader().createQuery().forEntitiesAtRevision(ChildEntity.class, 1).getSingleResult()
+                .equals(childVer1);
+
+        assert getAuditReader().createQuery().forEntitiesAtRevision(ParentEntity.class, 1).getSingleResult()
+                .equals(childVer1);
+    }
+}

Deleted: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/ChildVersioning.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/ChildVersioning.java	2008-11-14 15:16:23 UTC (rev 15565)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/ChildVersioning.java	2008-11-15 15:23:25 UTC (rev 15566)
@@ -1,92 +0,0 @@
-/*
- * 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.inheritance.single;
-
-import java.util.Arrays;
-import javax.persistence.EntityManager;
-
-import org.hibernate.envers.test.AbstractEntityTest;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import org.hibernate.ejb.Ejb3Configuration;
-
-/**
- * @author Adam Warski (adam at warski dot org)
- */
-public class ChildVersioning extends AbstractEntityTest {
-    private Integer id1;
-
-    public void configure(Ejb3Configuration cfg) {
-        cfg.addAnnotatedClass(ChildEntity.class);
-        cfg.addAnnotatedClass(ParentEntity.class);
-    }
-
-    @BeforeClass(dependsOnMethods = "init")
-    public void initData() {
-        EntityManager em = getEntityManager();
-
-        // Rev 1
-        em.getTransaction().begin();
-        ChildEntity ce = new ChildEntity("x", 1l);
-        em.persist(ce);
-        id1 = ce.getId();
-        em.getTransaction().commit();
-
-        // Rev 2
-        em.getTransaction().begin();
-        ce = em.find(ChildEntity.class, id1);
-        ce.setData("y");
-        ce.setNumber(2l);
-        em.getTransaction().commit();
-    }
-
-    @Test
-    public void testRevisionsCounts() {
-        assert Arrays.asList(1, 2).equals(getAuditReader().getRevisions(ChildEntity.class, id1));
-    }
-
-    @Test
-    public void testHistoryOfChildId1() {
-        ChildEntity ver1 = new ChildEntity(id1, "x", 1l);
-        ChildEntity ver2 = new ChildEntity(id1, "y", 2l);
-
-        assert getAuditReader().find(ChildEntity.class, id1, 1).equals(ver1);
-        assert getAuditReader().find(ChildEntity.class, id1, 2).equals(ver2);
-
-        assert getAuditReader().find(ParentEntity.class, id1, 1).equals(ver1);
-        assert getAuditReader().find(ParentEntity.class, id1, 2).equals(ver2);
-    }
-
-    @Test
-    public void testPolymorphicQuery() {
-        ChildEntity childVer1 = new ChildEntity(id1, "x", 1l);
-
-        assert getAuditReader().createQuery().forEntitiesAtRevision(ChildEntity.class, 1).getSingleResult()
-                .equals(childVer1);
-
-        assert getAuditReader().createQuery().forEntitiesAtRevision(ParentEntity.class, 1).getSingleResult()
-                .equals(childVer1);
-    }
-}

Copied: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/ParentAuditing.java (from rev 15550, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/ParentVersioning.java)
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/ParentAuditing.java	                        (rev 0)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/ParentAuditing.java	2008-11-15 15:23:25 UTC (rev 15566)
@@ -0,0 +1,93 @@
+/*
+ * 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.inheritance.single;
+
+import java.util.Arrays;
+import javax.persistence.EntityManager;
+
+import org.hibernate.envers.test.AbstractEntityTest;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import org.hibernate.ejb.Ejb3Configuration;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class ParentAuditing extends AbstractEntityTest {
+    private Integer id1;
+
+    public void configure(Ejb3Configuration cfg) {
+        cfg.addAnnotatedClass(ChildEntity.class);
+        cfg.addAnnotatedClass(ParentEntity.class);
+    }
+
+    @BeforeClass(dependsOnMethods = "init")
+    public void initData() {
+        EntityManager em = getEntityManager();
+
+        // Rev 1
+        em.getTransaction().begin();
+        ParentEntity pe = new ParentEntity("x");
+        em.persist(pe);
+        id1 = pe.getId();
+        em.getTransaction().commit();
+
+        // Rev 2
+        em.getTransaction().begin();
+        pe = em.find(ParentEntity.class, id1);
+        pe.setData("y");
+        em.getTransaction().commit();
+    }
+
+    @Test
+    public void testRevisionsCounts() {
+        assert Arrays.asList(1, 2).equals(getAuditReader().getRevisions(ParentEntity.class, id1));
+    }
+
+    @Test
+    public void testHistoryOfChildId1() {
+        assert getAuditReader().find(ChildEntity.class, id1, 1) == null;
+        assert getAuditReader().find(ChildEntity.class, id1, 2) == null;
+    }
+
+    @Test
+    public void testHistoryOfParentId1() {
+        ParentEntity ver1 = new ParentEntity(id1, "x");
+        ParentEntity ver2 = new ParentEntity(id1, "y");
+
+        assert getAuditReader().find(ParentEntity.class, id1, 1).equals(ver1);
+        assert getAuditReader().find(ParentEntity.class, id1, 2).equals(ver2);
+    }
+
+    @Test
+    public void testPolymorphicQuery() {
+        ParentEntity parentVer1 = new ParentEntity(id1, "x");
+
+        assert getAuditReader().createQuery().forEntitiesAtRevision(ParentEntity.class, 1).getSingleResult()
+                .equals(parentVer1);
+        assert getAuditReader().createQuery().forEntitiesAtRevision(ChildEntity.class, 1)
+                .getResultList().size() == 0;
+    }
+}
\ No newline at end of file

Deleted: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/ParentVersioning.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/ParentVersioning.java	2008-11-14 15:16:23 UTC (rev 15565)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/ParentVersioning.java	2008-11-15 15:23:25 UTC (rev 15566)
@@ -1,93 +0,0 @@
-/*
- * 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.inheritance.single;
-
-import java.util.Arrays;
-import javax.persistence.EntityManager;
-
-import org.hibernate.envers.test.AbstractEntityTest;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import org.hibernate.ejb.Ejb3Configuration;
-
-/**
- * @author Adam Warski (adam at warski dot org)
- */
-public class ParentVersioning extends AbstractEntityTest {
-    private Integer id1;
-
-    public void configure(Ejb3Configuration cfg) {
-        cfg.addAnnotatedClass(ChildEntity.class);
-        cfg.addAnnotatedClass(ParentEntity.class);
-    }
-
-    @BeforeClass(dependsOnMethods = "init")
-    public void initData() {
-        EntityManager em = getEntityManager();
-
-        // Rev 1
-        em.getTransaction().begin();
-        ParentEntity pe = new ParentEntity("x");
-        em.persist(pe);
-        id1 = pe.getId();
-        em.getTransaction().commit();
-
-        // Rev 2
-        em.getTransaction().begin();
-        pe = em.find(ParentEntity.class, id1);
-        pe.setData("y");
-        em.getTransaction().commit();
-    }
-
-    @Test
-    public void testRevisionsCounts() {
-        assert Arrays.asList(1, 2).equals(getAuditReader().getRevisions(ParentEntity.class, id1));
-    }
-
-    @Test
-    public void testHistoryOfChildId1() {
-        assert getAuditReader().find(ChildEntity.class, id1, 1) == null;
-        assert getAuditReader().find(ChildEntity.class, id1, 2) == null;
-    }
-
-    @Test
-    public void testHistoryOfParentId1() {
-        ParentEntity ver1 = new ParentEntity(id1, "x");
-        ParentEntity ver2 = new ParentEntity(id1, "y");
-
-        assert getAuditReader().find(ParentEntity.class, id1, 1).equals(ver1);
-        assert getAuditReader().find(ParentEntity.class, id1, 2).equals(ver2);
-    }
-
-    @Test
-    public void testPolymorphicQuery() {
-        ParentEntity parentVer1 = new ParentEntity(id1, "x");
-
-        assert getAuditReader().createQuery().forEntitiesAtRevision(ParentEntity.class, 1).getSingleResult()
-                .equals(parentVer1);
-        assert getAuditReader().createQuery().forEntitiesAtRevision(ChildEntity.class, 1)
-                .getResultList().size() == 0;
-    }
-}
\ No newline at end of file

Copied: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/notownedrelation (from rev 15565, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/inheritedrelation)

Modified: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/notownedrelation/Address.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/inheritedrelation/Address.java	2008-11-14 15:16:23 UTC (rev 15565)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/notownedrelation/Address.java	2008-11-15 15:23:25 UTC (rev 15566)
@@ -1,4 +1,4 @@
-package org.hibernate.envers.test.integration.inheritance.single.inheritedrelation;
+package org.hibernate.envers.test.integration.inheritance.single.notownedrelation;
 
 import org.hibernate.envers.Audited;
 

Modified: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/notownedrelation/Contact.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/inheritedrelation/Contact.java	2008-11-14 15:16:23 UTC (rev 15565)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/notownedrelation/Contact.java	2008-11-15 15:23:25 UTC (rev 15566)
@@ -1,4 +1,4 @@
-package org.hibernate.envers.test.integration.inheritance.single.inheritedrelation;
+package org.hibernate.envers.test.integration.inheritance.single.notownedrelation;
 
 import java.io.Serializable;
 import java.util.Set;

Deleted: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/notownedrelation/InheritedBidirectional.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/inheritedrelation/InheritedBidirectional.java	2008-11-14 15:16:23 UTC (rev 15565)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/notownedrelation/InheritedBidirectional.java	2008-11-15 15:23:25 UTC (rev 15566)
@@ -1,120 +0,0 @@
-/*
- * 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.inheritance.single.inheritedrelation;
-
-import java.util.Arrays;
-import javax.persistence.EntityManager;
-
-import org.hibernate.envers.test.AbstractEntityTest;
-import org.hibernate.envers.test.tools.TestTools;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import org.hibernate.ejb.Ejb3Configuration;
-
-/**
- * @author Adam Warski (adam at warski dot org)
- */
-public class InheritedBidirectional extends AbstractEntityTest {
-    private Long pc_id;
-    private Long a1_id;
-    private Long a2_id;
-
-    public void configure(Ejb3Configuration cfg) {
-        cfg.addAnnotatedClass(Address.class);
-        cfg.addAnnotatedClass(Contact.class);
-        cfg.addAnnotatedClass(PersonalContact.class);
-    }
-
-    @BeforeClass(dependsOnMethods = "init")
-    public void initData() {
-        EntityManager em = getEntityManager();
-
-        // Rev 1
-        em.getTransaction().begin();
-
-        PersonalContact pc = new PersonalContact();
-        pc.setEmail("e");
-        pc.setFirstname("f");
-
-        Address a1 = new Address();
-        a1.setAddress1("a1");
-        a1.setContact(pc);
-
-        em.persist(pc);
-        em.persist(a1);
-
-        em.getTransaction().commit();
-
-        // Rev 2
-        em.getTransaction().begin();
-
-        pc = em.find(PersonalContact.class, pc.getId());
-
-        Address a2 = new Address();
-        a2.setAddress1("a2");
-        a2.setContact(pc);
-
-        em.persist(a2);
-
-        em.getTransaction().commit();
-        
-        //
-
-        pc_id = pc.getId();
-        a1_id = a1.getId();
-        a2_id = a2.getId();
-    }
-
-    @Test
-    public void testRevisionsCounts() {
-        assert Arrays.asList(1, 2).equals(getAuditReader().getRevisions(Contact.class, pc_id));
-        assert Arrays.asList(1, 2).equals(getAuditReader().getRevisions(PersonalContact.class, pc_id));
-
-        assert Arrays.asList(1).equals(getAuditReader().getRevisions(Address.class, a1_id));
-        assert Arrays.asList(1).equals(getAuditReader().getRevisions(Address.class, a1_id));
-
-        assert Arrays.asList(2).equals(getAuditReader().getRevisions(Address.class, a2_id));
-        assert Arrays.asList(2).equals(getAuditReader().getRevisions(Address.class, a2_id));
-    }
-
-    @Test
-    public void testHistoryOfContact() {
-        assert getAuditReader().find(Contact.class, pc_id, 1).getAddresses().equals(
-                TestTools.makeSet(new Address(a1_id, "a1")));
-
-        assert getAuditReader().find(Contact.class, pc_id, 2).getAddresses().equals(
-                TestTools.makeSet(new Address(a1_id, "a1"), new Address(a2_id, "a2")));
-    }
-
-    @Test
-    public void testHistoryOfPersonalContact() {
-        assert getAuditReader().find(PersonalContact.class, pc_id, 1).getAddresses().equals(
-                TestTools.makeSet(new Address(a1_id, "a1")));
-
-        assert getAuditReader().find(PersonalContact.class, pc_id, 2).getAddresses().equals(
-                TestTools.makeSet(new Address(a1_id, "a1"), new Address(a2_id, "a2")));
-    }
-}
\ No newline at end of file

Added: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/notownedrelation/NotOwnedBidirectional.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/notownedrelation/NotOwnedBidirectional.java	                        (rev 0)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/notownedrelation/NotOwnedBidirectional.java	2008-11-15 15:23:25 UTC (rev 15566)
@@ -0,0 +1,120 @@
+/*
+ * 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.inheritance.single.notownedrelation;
+
+import java.util.Arrays;
+import javax.persistence.EntityManager;
+
+import org.hibernate.envers.test.AbstractEntityTest;
+import org.hibernate.envers.test.tools.TestTools;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import org.hibernate.ejb.Ejb3Configuration;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class NotOwnedBidirectional extends AbstractEntityTest {
+    private Long pc_id;
+    private Long a1_id;
+    private Long a2_id;
+
+    public void configure(Ejb3Configuration cfg) {
+        cfg.addAnnotatedClass(Address.class);
+        cfg.addAnnotatedClass(Contact.class);
+        cfg.addAnnotatedClass(PersonalContact.class);
+    }
+
+    @BeforeClass(dependsOnMethods = "init")
+    public void initData() {
+        EntityManager em = getEntityManager();
+
+        // Rev 1
+        em.getTransaction().begin();
+
+        PersonalContact pc = new PersonalContact();
+        pc.setEmail("e");
+        pc.setFirstname("f");
+
+        Address a1 = new Address();
+        a1.setAddress1("a1");
+        a1.setContact(pc);
+
+        em.persist(pc);
+        em.persist(a1);
+
+        em.getTransaction().commit();
+
+        // Rev 2
+        em.getTransaction().begin();
+
+        pc = em.find(PersonalContact.class, pc.getId());
+
+        Address a2 = new Address();
+        a2.setAddress1("a2");
+        a2.setContact(pc);
+
+        em.persist(a2);
+
+        em.getTransaction().commit();
+        
+        //
+
+        pc_id = pc.getId();
+        a1_id = a1.getId();
+        a2_id = a2.getId();
+    }
+
+    @Test
+    public void testRevisionsCounts() {
+        assert Arrays.asList(1, 2).equals(getAuditReader().getRevisions(Contact.class, pc_id));
+        assert Arrays.asList(1, 2).equals(getAuditReader().getRevisions(PersonalContact.class, pc_id));
+
+        assert Arrays.asList(1).equals(getAuditReader().getRevisions(Address.class, a1_id));
+        assert Arrays.asList(1).equals(getAuditReader().getRevisions(Address.class, a1_id));
+
+        assert Arrays.asList(2).equals(getAuditReader().getRevisions(Address.class, a2_id));
+        assert Arrays.asList(2).equals(getAuditReader().getRevisions(Address.class, a2_id));
+    }
+
+    @Test
+    public void testHistoryOfContact() {
+        assert getAuditReader().find(Contact.class, pc_id, 1).getAddresses().equals(
+                TestTools.makeSet(new Address(a1_id, "a1")));
+
+        assert getAuditReader().find(Contact.class, pc_id, 2).getAddresses().equals(
+                TestTools.makeSet(new Address(a1_id, "a1"), new Address(a2_id, "a2")));
+    }
+
+    @Test
+    public void testHistoryOfPersonalContact() {
+        assert getAuditReader().find(PersonalContact.class, pc_id, 1).getAddresses().equals(
+                TestTools.makeSet(new Address(a1_id, "a1")));
+
+        assert getAuditReader().find(PersonalContact.class, pc_id, 2).getAddresses().equals(
+                TestTools.makeSet(new Address(a1_id, "a1"), new Address(a2_id, "a2")));
+    }
+}
\ No newline at end of file


Property changes on: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/notownedrelation/NotOwnedBidirectional.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Modified: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/notownedrelation/PersonalContact.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/inheritedrelation/PersonalContact.java	2008-11-14 15:16:23 UTC (rev 15565)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/notownedrelation/PersonalContact.java	2008-11-15 15:23:25 UTC (rev 15566)
@@ -1,4 +1,4 @@
-package org.hibernate.envers.test.integration.inheritance.single.inheritedrelation;
+package org.hibernate.envers.test.integration.inheritance.single.notownedrelation;
 
 import javax.persistence.DiscriminatorValue;
 import javax.persistence.Entity;

Added: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/ChildAuditing.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/ChildAuditing.java	                        (rev 0)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/ChildAuditing.java	2008-11-15 15:23:25 UTC (rev 15566)
@@ -0,0 +1,94 @@
+/*
+ * 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.inheritance.tableperclass;
+
+import java.util.Arrays;
+import javax.persistence.EntityManager;
+
+import org.hibernate.envers.test.AbstractEntityTest;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import org.hibernate.ejb.Ejb3Configuration;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class ChildAuditing extends AbstractEntityTest {
+    private Integer id1;
+
+    public void configure(Ejb3Configuration cfg) {
+        cfg.addAnnotatedClass(ChildEntity.class);
+        cfg.addAnnotatedClass(ParentEntity.class);
+    }
+
+    @BeforeClass(dependsOnMethods = "init")
+    public void initData() {
+        EntityManager em = getEntityManager();
+
+        id1 = 1;
+
+        // Rev 1
+        em.getTransaction().begin();
+        ChildEntity ce = new ChildEntity(id1, "x", 1l);
+        em.persist(ce);
+        em.getTransaction().commit();
+
+        // Rev 2
+        em.getTransaction().begin();
+        ce = em.find(ChildEntity.class, id1);
+        ce.setData("y");
+        ce.setNumber(2l);
+        em.getTransaction().commit();
+    }
+
+    @Test
+    public void testRevisionsCounts() {
+        assert Arrays.asList(1, 2).equals(getAuditReader().getRevisions(ChildEntity.class, id1));
+    }
+
+    @Test
+    public void testHistoryOfChildId1() {
+        ChildEntity ver1 = new ChildEntity(id1, "x", 1l);
+        ChildEntity ver2 = new ChildEntity(id1, "y", 2l);
+
+        assert getAuditReader().find(ChildEntity.class, id1, 1).equals(ver1);
+        assert getAuditReader().find(ChildEntity.class, id1, 2).equals(ver2);
+
+        assert getAuditReader().find(ParentEntity.class, id1, 1).equals(ver1);
+        assert getAuditReader().find(ParentEntity.class, id1, 2).equals(ver2);
+    }
+
+    @Test
+    public void testPolymorphicQuery() {
+        ChildEntity childVer1 = new ChildEntity(id1, "x", 1l);
+
+        assert getAuditReader().createQuery().forEntitiesAtRevision(ChildEntity.class, 1).getSingleResult()
+                .equals(childVer1);
+
+        assert getAuditReader().createQuery().forEntitiesAtRevision(ParentEntity.class, 1).getSingleResult()
+                .equals(childVer1);
+    }
+}
\ No newline at end of file

Copied: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/ChildEntity.java (from rev 15550, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/ChildEntity.java)
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/ChildEntity.java	                        (rev 0)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/ChildEntity.java	2008-11-15 15:23:25 UTC (rev 15566)
@@ -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.inheritance.tableperclass;
+
+import javax.persistence.Basic;
+import javax.persistence.Entity;
+
+import org.hibernate.envers.Audited;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+ at Entity
+ at Audited
+public class ChildEntity extends ParentEntity {
+    @Basic
+    private Long number;
+
+    public ChildEntity() {
+    }
+
+    public ChildEntity(Integer id, String data, Long number) {
+        super(id, data);
+        this.number = number;
+    }
+
+    public Long getNumber() {
+        return number;
+    }
+
+    public void setNumber(Long number) {
+        this.number = number;
+    }
+
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (!(o instanceof ChildEntity)) return false;
+        if (!super.equals(o)) return false;
+
+        ChildEntity childEntity = (ChildEntity) o;
+
+        if (number != null ? !number.equals(childEntity.number) : childEntity.number != null) return false;
+
+        return true;
+    }
+
+    public int hashCode() {
+        int result = super.hashCode();
+        result = 31 * result + (number != null ? number.hashCode() : 0);
+        return result;
+    }
+
+    public String toString() {
+        return "ChildEntity(id = " + getId() + ", data = " + getData() + ", number = " + number + ")";
+    }
+}
\ No newline at end of file


Property changes on: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/ChildEntity.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Added: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/ParentAuditing.java
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/ParentAuditing.java	                        (rev 0)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/ParentAuditing.java	2008-11-15 15:23:25 UTC (rev 15566)
@@ -0,0 +1,95 @@
+/*
+ * 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.inheritance.tableperclass;
+
+import java.util.Arrays;
+import javax.persistence.EntityManager;
+
+import org.hibernate.envers.test.AbstractEntityTest;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import org.hibernate.ejb.Ejb3Configuration;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class ParentAuditing extends AbstractEntityTest {
+    private Integer id1;
+
+    public void configure(Ejb3Configuration cfg) {
+        cfg.addAnnotatedClass(ChildEntity.class);
+        cfg.addAnnotatedClass(ParentEntity.class);
+    }
+
+    @BeforeClass(dependsOnMethods = "init")
+    public void initData() {
+        EntityManager em = getEntityManager();
+
+        id1 = 1;
+
+        // Rev 1
+        em.getTransaction().begin();
+        ParentEntity pe = new ParentEntity(id1, "x");
+        em.persist(pe);
+        em.getTransaction().commit();
+
+        // Rev 2
+        em.getTransaction().begin();
+        pe = em.find(ParentEntity.class, id1);
+        pe.setData("y");
+        em.getTransaction().commit();
+    }
+
+    @Test
+    public void testRevisionsCounts() {
+        assert Arrays.asList(1, 2).equals(getAuditReader().getRevisions(ParentEntity.class, id1));
+    }
+
+    @Test
+    public void testHistoryOfChildId1() {
+        assert getAuditReader().find(ChildEntity.class, id1, 1) == null;
+        assert getAuditReader().find(ChildEntity.class, id1, 2) == null;
+    }
+
+    @Test
+    public void testHistoryOfParentId1() {
+        ParentEntity ver1 = new ParentEntity(id1, "x");
+        ParentEntity ver2 = new ParentEntity(id1, "y");
+
+        assert getAuditReader().find(ParentEntity.class, id1, 1).equals(ver1);
+        assert getAuditReader().find(ParentEntity.class, id1, 2).equals(ver2);
+    }
+
+    @Test
+    public void testPolymorphicQuery() {
+        ParentEntity parentVer1 = new ParentEntity(id1, "x");
+
+        assert getAuditReader().createQuery().forEntitiesAtRevision(ParentEntity.class, 1).getSingleResult()
+                .equals(parentVer1);
+        assert getAuditReader().createQuery().forEntitiesAtRevision(ChildEntity.class, 1)
+                .getResultList().size() == 0;
+    }
+}
\ No newline at end of file

Copied: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/ParentEntity.java (from rev 15550, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/ParentEntity.java)
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/ParentEntity.java	                        (rev 0)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/ParentEntity.java	2008-11-15 15:23:25 UTC (rev 15566)
@@ -0,0 +1,95 @@
+/*
+ * 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.inheritance.tableperclass;
+
+import javax.persistence.Basic;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+
+import org.hibernate.envers.Audited;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+ at Entity
+ at Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+ at Audited
+public class ParentEntity {
+    @Id
+    private Integer id;
+
+    @Basic
+    private String data;
+
+    public ParentEntity() {
+    }
+
+    public ParentEntity(Integer id, String data) {
+        this.id = id;
+        this.data = data;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getData() {
+        return data;
+    }
+
+    public void setData(String data) {
+        this.data = data;
+    }
+
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (!(o instanceof ParentEntity)) return false;
+
+        ParentEntity that = (ParentEntity) o;
+
+        if (data != null ? !data.equals(that.data) : that.data != null) return false;
+        if (id != null ? !id.equals(that.id) : that.id != null) return false;
+
+        return true;
+    }
+
+    public int hashCode() {
+        int result;
+        result = (id != null ? id.hashCode() : 0);
+        result = 31 * result + (data != null ? data.hashCode() : 0);
+        return result;
+    }
+
+    public String toString() {
+        return "ParentEntity(id = " + getId() + ", data = " + getData() + ")";
+    }
+}
\ No newline at end of file


Property changes on: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/ParentEntity.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/childrelation/ChildIngEntity.java (from rev 15550, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/childrelation/ChildIngEntity.java)
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/childrelation/ChildIngEntity.java	                        (rev 0)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/childrelation/ChildIngEntity.java	2008-11-15 15:23:25 UTC (rev 15566)
@@ -0,0 +1,90 @@
+/*
+ * 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.inheritance.tableperclass.childrelation;
+
+import javax.persistence.Basic;
+import javax.persistence.Entity;
+import javax.persistence.ManyToOne;
+
+import org.hibernate.envers.Audited;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+ at Entity
+ at Audited
+public class ChildIngEntity extends ParentNotIngEntity {
+    @Basic
+    private Long number;
+
+    @ManyToOne
+    private ReferencedEntity referenced;
+
+    public ChildIngEntity() {
+    }
+
+    public ChildIngEntity(Integer id, String data, Long number) {
+        super(id, data);
+        this.number = number;
+    }
+
+    public Long getNumber() {
+        return number;
+    }
+
+    public void setNumber(Long number) {
+        this.number = number;
+    }
+
+    public ReferencedEntity getReferenced() {
+        return referenced;
+    }
+
+    public void setReferenced(ReferencedEntity referenced) {
+        this.referenced = referenced;
+    }
+
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (!(o instanceof ChildIngEntity)) return false;
+        if (!super.equals(o)) return false;
+
+        ChildIngEntity childEntity = (ChildIngEntity) o;
+
+        if (number != null ? !number.equals(childEntity.number) : childEntity.number != null) return false;
+
+        return true;
+    }
+
+    public int hashCode() {
+        int result = super.hashCode();
+        result = 31 * result + (number != null ? number.hashCode() : 0);
+        return result;
+    }
+
+    public String toString() {
+        return "ChildIngEntity(id = " + getId() + ", data = " + getData() + ", number = " + number + ")";
+    }
+}
\ No newline at end of file


Property changes on: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/childrelation/ChildIngEntity.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/childrelation/ChildReferencing.java (from rev 15550, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/childrelation/ChildReferencing.java)
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/childrelation/ChildReferencing.java	                        (rev 0)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/childrelation/ChildReferencing.java	2008-11-15 15:23:25 UTC (rev 15566)
@@ -0,0 +1,124 @@
+/*
+ * 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.inheritance.tableperclass.childrelation;
+
+import java.util.Arrays;
+import javax.persistence.EntityManager;
+
+import org.hibernate.envers.test.AbstractEntityTest;
+import org.hibernate.envers.test.tools.TestTools;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import org.hibernate.ejb.Ejb3Configuration;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class ChildReferencing extends AbstractEntityTest {
+    private Integer re_id1;
+    private Integer re_id2;
+    private Integer c_id;
+
+    public void configure(Ejb3Configuration cfg) {
+        cfg.addAnnotatedClass(ChildIngEntity.class);
+        cfg.addAnnotatedClass(ParentNotIngEntity.class);
+        cfg.addAnnotatedClass(ReferencedEntity.class);
+    }
+
+    @BeforeClass(dependsOnMethods = "init")
+    public void initData() {
+        EntityManager em = getEntityManager();
+
+        re_id1 = 1;
+        re_id2 = 10;
+        c_id = 100;
+
+        // Rev 1
+        em.getTransaction().begin();
+
+        ReferencedEntity re1 = new ReferencedEntity(re_id1);
+        em.persist(re1);
+
+        ReferencedEntity re2 = new ReferencedEntity(re_id2);
+        em.persist(re2);
+
+        em.getTransaction().commit();
+
+        // Rev 2
+        em.getTransaction().begin();
+
+        re1 = em.find(ReferencedEntity.class, re_id1);
+
+        ChildIngEntity cie = new ChildIngEntity(c_id, "y", 1l);
+        cie.setReferenced(re1);
+        em.persist(cie);
+        c_id = cie.getId();
+
+        em.getTransaction().commit();
+
+        // Rev 3
+        em.getTransaction().begin();
+
+        re2 = em.find(ReferencedEntity.class, re_id2);
+        cie = em.find(ChildIngEntity.class, c_id);
+
+        cie.setReferenced(re2);
+
+        em.getTransaction().commit();
+    }
+
+    @Test
+    public void testRevisionsCounts() {
+        assert Arrays.asList(1, 2, 3).equals(getAuditReader().getRevisions(ReferencedEntity.class, re_id1));
+        assert Arrays.asList(1, 3).equals(getAuditReader().getRevisions(ReferencedEntity.class, re_id2));
+        assert Arrays.asList(2, 3).equals(getAuditReader().getRevisions(ChildIngEntity.class, c_id));
+    }
+
+    @Test
+    public void testHistoryOfReferencedCollection1() {
+        assert getAuditReader().find(ReferencedEntity.class, re_id1, 1).getReferencing().size() == 0;
+        assert getAuditReader().find(ReferencedEntity.class, re_id1, 2).getReferencing().equals(
+                TestTools.makeSet(new ChildIngEntity(c_id, "y", 1l)));
+        assert getAuditReader().find(ReferencedEntity.class, re_id1, 3).getReferencing().size() == 0;
+    }
+
+    @Test
+    public void testHistoryOfReferencedCollection2() {
+        assert getAuditReader().find(ReferencedEntity.class, re_id2, 1).getReferencing().size() == 0;
+        assert getAuditReader().find(ReferencedEntity.class, re_id2, 2).getReferencing().size() == 0;
+        assert getAuditReader().find(ReferencedEntity.class, re_id2, 3).getReferencing().equals(
+                TestTools.makeSet(new ChildIngEntity(c_id, "y", 1l)));
+    }
+
+    @Test
+    public void testChildHistory() {
+        assert getAuditReader().find(ChildIngEntity.class, c_id, 1) == null;
+        assert getAuditReader().find(ChildIngEntity.class, c_id, 2).getReferenced().equals(
+                new ReferencedEntity(re_id1));
+        assert getAuditReader().find(ChildIngEntity.class, c_id, 3).getReferenced().equals(
+                new ReferencedEntity(re_id2));
+    }
+}
\ No newline at end of file


Property changes on: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/childrelation/ChildReferencing.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/childrelation/ParentNotIngEntity.java (from rev 15550, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/childrelation/ParentNotIngEntity.java)
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/childrelation/ParentNotIngEntity.java	                        (rev 0)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/childrelation/ParentNotIngEntity.java	2008-11-15 15:23:25 UTC (rev 15566)
@@ -0,0 +1,94 @@
+/*
+ * 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.inheritance.tableperclass.childrelation;
+
+import javax.persistence.Basic;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+
+import org.hibernate.envers.Audited;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+ at Entity
+ at Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+ at Audited
+public class ParentNotIngEntity {
+    @Id
+    private Integer id;
+
+    @Basic
+    private String data;
+
+    public ParentNotIngEntity() {
+    }
+
+    public ParentNotIngEntity(Integer id, String data) {
+        this.id = id;
+        this.data = data;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getData() {
+        return data;
+    }
+
+    public void setData(String data) {
+        this.data = data;
+    }
+
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (!(o instanceof ParentNotIngEntity)) return false;
+
+        ParentNotIngEntity that = (ParentNotIngEntity) o;
+
+        if (data != null ? !data.equals(that.data) : that.data != null) return false;
+        if (id != null ? !id.equals(that.id) : that.id != null) return false;
+
+        return true;
+    }
+
+    public int hashCode() {
+        int result;
+        result = (id != null ? id.hashCode() : 0);
+        result = 31 * result + (data != null ? data.hashCode() : 0);
+        return result;
+    }
+
+    public String toString() {
+        return "ParentNotIngEntity(id = " + getId() + ", data = " + getData() + ")";
+    }
+}
\ No newline at end of file


Property changes on: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/childrelation/ParentNotIngEntity.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/childrelation/ReferencedEntity.java (from rev 15550, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/childrelation/ReferencedEntity.java)
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/childrelation/ReferencedEntity.java	                        (rev 0)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/childrelation/ReferencedEntity.java	2008-11-15 15:23:25 UTC (rev 15566)
@@ -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.inheritance.tableperclass.childrelation;
+
+import java.util.Set;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+
+import org.hibernate.envers.Audited;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+ at Entity
+ at Audited
+public class ReferencedEntity {
+    @Id
+    private Integer id;
+
+    @OneToMany(mappedBy = "referenced")
+    private Set<ChildIngEntity> referencing;
+
+    public ReferencedEntity(Integer id) {
+        this.id = id;
+    }
+
+    public ReferencedEntity() {
+    }
+
+    public Set<ChildIngEntity> getReferencing() {
+        return referencing;
+    }
+
+    public void setReferencing(Set<ChildIngEntity> referencing) {
+        this.referencing = referencing;
+    }
+
+    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 ReferencedEntity)) return false;
+
+        ReferencedEntity that = (ReferencedEntity) o;
+
+        if (id != null ? !id.equals(that.id) : that.id != null) return false;
+
+        return true;
+    }
+
+    public int hashCode() {
+        return id;
+    }
+
+    public String toString() {
+        return "ReferencedEntity(id = " + getId() + ")";
+    }
+}
\ No newline at end of file


Property changes on: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/childrelation/ReferencedEntity.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/notownedrelation/Address.java (from rev 15565, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/inheritedrelation/Address.java)
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/notownedrelation/Address.java	                        (rev 0)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/notownedrelation/Address.java	2008-11-15 15:23:25 UTC (rev 15566)
@@ -0,0 +1,100 @@
+/*
+ * 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.inheritance.tableperclass.notownedrelation;
+
+import org.hibernate.envers.Audited;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+
+ at Entity
+ at Audited
+public class Address implements Serializable {
+	@Id
+	private Long id;
+
+	private String address1;
+
+	@ManyToOne
+	private Contact contact;
+
+    public Address() {
+    }
+
+    public Address(Long id, String address1) {
+        this.id = id;
+        this.address1 = address1;
+    }
+
+    public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public String getAddress1() {
+		return address1;
+	}
+
+	public void setAddress1(String address1) {
+		this.address1 = address1;
+	}
+
+	public Contact getContact() {
+		return contact;
+	}
+
+	public void setContact(Contact contact) {
+		this.contact = contact;
+	}
+
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (!(o instanceof Address)) return false;
+
+        Address address = (Address) o;
+
+        if (address1 != null ? !address1.equals(address.address1) : address.address1 != null) return false;
+        if (id != null ? !id.equals(address.id) : address.id != null) return false;
+
+        return true;
+    }
+
+    public int hashCode() {
+        int result;
+        result = (id != null ? id.hashCode() : 0);
+        result = 31 * result + (address1 != null ? address1.hashCode() : 0);
+        return result;
+    }
+
+    public String toString() {
+        return "Address(id = " + getId() + ", address1 = " + getAddress1() + ")";
+    }
+}
\ No newline at end of file


Property changes on: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/notownedrelation/Address.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/notownedrelation/Contact.java (from rev 15565, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/inheritedrelation/Contact.java)
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/notownedrelation/Contact.java	                        (rev 0)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/notownedrelation/Contact.java	2008-11-15 15:23:25 UTC (rev 15566)
@@ -0,0 +1,77 @@
+/*
+ * 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.inheritance.tableperclass.notownedrelation;
+
+import java.io.Serializable;
+import java.util.Set;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.OneToMany;
+
+import org.hibernate.envers.Audited;
+
+ at Entity
+ at Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
+ at Audited
+public class Contact implements Serializable {
+    @Id
+    private Long id;
+
+    private String email;
+
+    @OneToMany(mappedBy="contact")
+    private Set<Address> addresses;
+
+    public Contact() {
+    }
+
+    public Contact(Long id, String email) {
+        this.id = id;
+        this.email = email;
+    }
+
+    public Long getId() {
+        return id;
+    }
+    public void setId(Long id) {
+        this.id = id;
+    }
+	public String getEmail() {
+        return email;
+    }
+    public void setEmail(String email) {
+        this.email = email;
+    }
+
+    public Set<Address> getAddresses() {
+        return addresses;
+    }
+    public void setAddresses(Set<Address> addresses) {
+        this.addresses = addresses;
+    }
+}
\ No newline at end of file


Property changes on: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/notownedrelation/Contact.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/notownedrelation/NotOwnedBidirectional.java (from rev 15565, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/inheritedrelation/InheritedBidirectional.java)
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/notownedrelation/NotOwnedBidirectional.java	                        (rev 0)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/notownedrelation/NotOwnedBidirectional.java	2008-11-15 15:23:25 UTC (rev 15566)
@@ -0,0 +1,115 @@
+/*
+ * 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.inheritance.tableperclass.notownedrelation;
+
+import java.util.Arrays;
+import javax.persistence.EntityManager;
+
+import org.hibernate.envers.test.AbstractEntityTest;
+import org.hibernate.envers.test.tools.TestTools;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import org.hibernate.ejb.Ejb3Configuration;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class NotOwnedBidirectional extends AbstractEntityTest {
+    private Long pc_id;
+    private Long a1_id;
+    private Long a2_id;
+
+    public void configure(Ejb3Configuration cfg) {
+        cfg.addAnnotatedClass(Address.class);
+        cfg.addAnnotatedClass(Contact.class);
+        cfg.addAnnotatedClass(PersonalContact.class);
+    }
+
+    @BeforeClass(dependsOnMethods = "init")
+    public void initData() {
+        EntityManager em = getEntityManager();
+
+        pc_id = 1l;
+        a1_id = 10l;
+        a2_id = 100l;
+
+        // Rev 1
+        em.getTransaction().begin();
+
+        PersonalContact pc = new PersonalContact(pc_id, "e", "f");
+
+        Address a1 = new Address(a1_id, "a1");
+        a1.setContact(pc);
+
+        em.persist(pc);
+        em.persist(a1);
+
+        em.getTransaction().commit();
+
+        // Rev 2
+        em.getTransaction().begin();
+
+        pc = em.find(PersonalContact.class, pc_id);
+
+        Address a2 = new Address(a2_id, "a2");
+        a2.setContact(pc);
+
+        em.persist(a2);
+
+        em.getTransaction().commit();
+    }
+
+    @Test
+    public void testRevisionsCounts() {
+        assert Arrays.asList(1, 2).equals(getAuditReader().getRevisions(Contact.class, pc_id));
+        assert Arrays.asList(1, 2).equals(getAuditReader().getRevisions(PersonalContact.class, pc_id));
+
+        assert Arrays.asList(1).equals(getAuditReader().getRevisions(Address.class, a1_id));
+        assert Arrays.asList(1).equals(getAuditReader().getRevisions(Address.class, a1_id));
+
+        assert Arrays.asList(2).equals(getAuditReader().getRevisions(Address.class, a2_id));
+        assert Arrays.asList(2).equals(getAuditReader().getRevisions(Address.class, a2_id));
+    }
+
+    @Test
+    public void testHistoryOfContact() {
+        assert getAuditReader().find(Contact.class, pc_id, 1).getAddresses().equals(
+                TestTools.makeSet(new Address(a1_id, "a1")));
+
+        assert getAuditReader().find(Contact.class, pc_id, 2).getAddresses().equals(
+                TestTools.makeSet(new Address(a1_id, "a1"), new Address(a2_id, "a2")));
+    }
+
+    @Test
+    public void testHistoryOfPersonalContact() {
+        System.out.println(getAuditReader().find(PersonalContact.class, pc_id, 1).getAddresses());
+        assert getAuditReader().find(PersonalContact.class, pc_id, 1).getAddresses().equals(
+                TestTools.makeSet(new Address(a1_id, "a1")));
+
+        assert getAuditReader().find(PersonalContact.class, pc_id, 2).getAddresses().equals(
+                TestTools.makeSet(new Address(a1_id, "a1"), new Address(a2_id, "a2")));
+    }
+}
\ No newline at end of file


Property changes on: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/notownedrelation/NotOwnedBidirectional.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/notownedrelation/PersonalContact.java (from rev 15565, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/inheritedrelation/PersonalContact.java)
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/notownedrelation/PersonalContact.java	                        (rev 0)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/notownedrelation/PersonalContact.java	2008-11-15 15:23:25 UTC (rev 15566)
@@ -0,0 +1,51 @@
+/*
+ * 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.inheritance.tableperclass.notownedrelation;
+
+import javax.persistence.Entity;
+
+import org.hibernate.envers.Audited;
+
+ at Entity
+ at Audited
+public class PersonalContact extends Contact {
+    private String firstname;
+
+    public PersonalContact() {
+    }
+
+    public PersonalContact(Long id, String email, String firstname) {
+        super(id, email);
+        this.firstname = firstname;
+    }
+
+    public String getFirstname() {
+		return firstname;
+	}
+
+    public void setFirstname(String firstname) {
+		this.firstname = firstname;
+	}
+}
\ No newline at end of file


Property changes on: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/notownedrelation/PersonalContact.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/relation/ChildIngEntity.java (from rev 15550, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/relation/ChildIngEntity.java)
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/relation/ChildIngEntity.java	                        (rev 0)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/relation/ChildIngEntity.java	2008-11-15 15:23:25 UTC (rev 15566)
@@ -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.inheritance.tableperclass.relation;
+
+import javax.persistence.Basic;
+import javax.persistence.Entity;
+
+import org.hibernate.envers.Audited;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+ at Entity
+ at Audited
+public class ChildIngEntity extends ParentIngEntity {
+    @Basic
+    private Long number;
+
+    public ChildIngEntity() {
+    }
+
+    public ChildIngEntity(Integer id, String data, Long number) {
+        super(id, data);
+        this.number = number;
+    }
+
+    public Long getNumber() {
+        return number;
+    }
+
+    public void setNumber(Long number) {
+        this.number = number;
+    }
+
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (!(o instanceof ChildIngEntity)) return false;
+        if (!super.equals(o)) return false;
+
+        ChildIngEntity childEntity = (ChildIngEntity) o;
+
+        if (number != null ? !number.equals(childEntity.number) : childEntity.number != null) return false;
+
+        return true;
+    }
+
+    public int hashCode() {
+        int result = super.hashCode();
+        result = 31 * result + (number != null ? number.hashCode() : 0);
+        return result;
+    }
+
+    public String toString() {
+        return "ChildIngEntity(id = " + getId() + ", data = " + getData() + ", number = " + number + ")";
+    }
+}
\ No newline at end of file


Property changes on: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/relation/ChildIngEntity.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/relation/ParentIngEntity.java (from rev 15550, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/relation/ParentIngEntity.java)
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/relation/ParentIngEntity.java	                        (rev 0)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/relation/ParentIngEntity.java	2008-11-15 15:23:25 UTC (rev 15566)
@@ -0,0 +1,106 @@
+/*
+ * 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.inheritance.tableperclass.relation;
+
+import javax.persistence.Basic;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.ManyToOne;
+
+import org.hibernate.envers.Audited;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+ at Entity
+ at Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+ at Audited
+public class ParentIngEntity {
+    @Id
+    private Integer id;
+
+    @Basic
+    private String data;
+
+    @ManyToOne
+    private ReferencedEntity referenced;
+
+    public ParentIngEntity() {
+    }
+
+    public ParentIngEntity(Integer id, String data) {
+        this.id = id;
+        this.data = data;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getData() {
+        return data;
+    }
+
+    public void setData(String data) {
+        this.data = data;
+    }
+
+    public ReferencedEntity getReferenced() {
+        return referenced;
+    }
+
+    public void setReferenced(ReferencedEntity referenced) {
+        this.referenced = referenced;
+    }
+
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (!(o instanceof ParentIngEntity)) return false;
+
+        ParentIngEntity that = (ParentIngEntity) o;
+
+        if (data != null ? !data.equals(that.data) : that.data != null) return false;
+        if (id != null ? !id.equals(that.id) : that.id != null) return false;
+
+        return true;
+    }
+
+    public int hashCode() {
+        int result;
+        result = (id != null ? id.hashCode() : 0);
+        result = 31 * result + (data != null ? data.hashCode() : 0);
+        return result;
+    }
+
+    public String toString() {
+        return "ParentIngEntity(id = " + getId() + ", data = " + getData() + ")";
+    }
+}
\ No newline at end of file


Property changes on: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/relation/ParentIngEntity.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/relation/PolymorphicCollection.java (from rev 15550, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/relation/PolymorphicCollection.java)
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/relation/PolymorphicCollection.java	                        (rev 0)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/relation/PolymorphicCollection.java	2008-11-15 15:23:25 UTC (rev 15566)
@@ -0,0 +1,107 @@
+/*
+ * 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.inheritance.tableperclass.relation;
+
+import java.util.Arrays;
+import javax.persistence.EntityManager;
+
+import org.hibernate.envers.test.AbstractEntityTest;
+import org.hibernate.envers.test.tools.TestTools;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import org.hibernate.ejb.Ejb3Configuration;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class PolymorphicCollection extends AbstractEntityTest {
+    private Integer ed_id1;
+    private Integer c_id;
+    private Integer p_id;
+
+    public void configure(Ejb3Configuration cfg) {
+        cfg.addAnnotatedClass(ChildIngEntity.class);
+        cfg.addAnnotatedClass(ParentIngEntity.class);
+        cfg.addAnnotatedClass(ReferencedEntity.class);
+    }
+
+    @BeforeClass(dependsOnMethods = "init")
+    public void initData() {
+        EntityManager em = getEntityManager();
+
+        ed_id1 = 1;
+        p_id = 10;
+        c_id = 100;
+
+        // Rev 1
+        em.getTransaction().begin();
+
+        ReferencedEntity re = new ReferencedEntity(ed_id1);
+        em.persist(re);
+
+        em.getTransaction().commit();
+
+        // Rev 2
+        em.getTransaction().begin();
+
+        re = em.find(ReferencedEntity.class, ed_id1);
+
+        ParentIngEntity pie = new ParentIngEntity(p_id,"x");
+        pie.setReferenced(re);
+        em.persist(pie);
+        p_id = pie.getId();
+
+        em.getTransaction().commit();
+
+        // Rev 3
+        em.getTransaction().begin();
+
+        re = em.find(ReferencedEntity.class, ed_id1);
+
+        ChildIngEntity cie = new ChildIngEntity(c_id, "y", 1l);
+        cie.setReferenced(re);
+        em.persist(cie);
+        c_id = cie.getId();
+
+        em.getTransaction().commit();
+    }
+
+    @Test
+    public void testRevisionsCounts() {
+        assert Arrays.asList(1, 2, 3).equals(getAuditReader().getRevisions(ReferencedEntity.class, ed_id1));
+        assert Arrays.asList(2).equals(getAuditReader().getRevisions(ParentIngEntity.class, p_id));
+        assert Arrays.asList(3).equals(getAuditReader().getRevisions(ChildIngEntity.class, c_id));
+    }
+
+    @Test
+    public void testHistoryOfReferencedCollection() {
+        assert getAuditReader().find(ReferencedEntity.class, ed_id1, 1).getReferencing().size() == 0;
+        assert getAuditReader().find(ReferencedEntity.class, ed_id1, 2).getReferencing().equals(
+                TestTools.makeSet(new ParentIngEntity(p_id, "x")));
+        assert getAuditReader().find(ReferencedEntity.class, ed_id1, 3).getReferencing().equals(
+                TestTools.makeSet(new ParentIngEntity(p_id, "x"), new ChildIngEntity(c_id, "y", 1l)));
+    }
+}
\ No newline at end of file


Property changes on: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/relation/PolymorphicCollection.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/relation/ReferencedEntity.java (from rev 15550, core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/single/relation/ReferencedEntity.java)
===================================================================
--- core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/relation/ReferencedEntity.java	                        (rev 0)
+++ core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/relation/ReferencedEntity.java	2008-11-15 15:23:25 UTC (rev 15566)
@@ -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.inheritance.tableperclass.relation;
+
+import java.util.Set;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+
+import org.hibernate.envers.Audited;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+ at Entity
+ at Audited
+public class ReferencedEntity {
+    @Id
+    private Integer id;
+
+    @OneToMany(mappedBy = "referenced")
+    private Set<ParentIngEntity> referencing;
+
+    public ReferencedEntity() {
+    }
+
+    public ReferencedEntity(Integer id) {
+        this.id = id;
+    }
+
+    public Set<ParentIngEntity> getReferencing() {
+        return referencing;
+    }
+
+    public void setReferencing(Set<ParentIngEntity> referencing) {
+        this.referencing = referencing;
+    }
+
+    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 ReferencedEntity)) return false;
+
+        ReferencedEntity that = (ReferencedEntity) o;
+
+        if (id != null ? !id.equals(that.id) : that.id != null) return false;
+
+        return true;
+    }
+
+    public int hashCode() {
+        return id;
+    }
+
+    public String toString() {
+        return "ReferencedEntity(id = " + getId() + ")";
+    }
+}
\ No newline at end of file


Property changes on: core/trunk/envers/src/test/java/org/hibernate/envers/test/integration/inheritance/tableperclass/relation/ReferencedEntity.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Modified: core/trunk/envers/src/test/resources/testng.xml
===================================================================
--- core/trunk/envers/src/test/resources/testng.xml	2008-11-14 15:16:23 UTC (rev 15565)
+++ core/trunk/envers/src/test/resources/testng.xml	2008-11-15 15:23:25 UTC (rev 15566)
@@ -15,8 +15,12 @@
             <package name="org.hibernate.envers.test.integration.ids" />
             <package name="org.hibernate.envers.test.integration.inheritance.single" />
             <package name="org.hibernate.envers.test.integration.inheritance.single.childrelation" />
-            <package name="org.hibernate.envers.test.integration.inheritance.single.inheritedrelation" />
+            <package name="org.hibernate.envers.test.integration.inheritance.single.notownedrelation" />
             <package name="org.hibernate.envers.test.integration.inheritance.single.relation" />
+            <package name="org.hibernate.envers.test.integration.inheritance.tableperclass" />
+            <package name="org.hibernate.envers.test.integration.inheritance.tableperclass.childrelation" />
+            <package name="org.hibernate.envers.test.integration.inheritance.tableperclass.notownedrelation" />
+            <package name="org.hibernate.envers.test.integration.inheritance.tableperclass.relation" />
             <package name="org.hibernate.envers.test.integration.manytomany" />
             <package name="org.hibernate.envers.test.integration.manytomany.ternary" />
             <package name="org.hibernate.envers.test.integration.manytomany.unidirectional" />




More information about the hibernate-commits mailing list