JBoss Envers SVN: r97 - in trunk/src: main/org/jboss/envers/entity and 5 other directories.
by jboss-envers-commits@lists.jboss.org
Author: adamw
Date: 2008-07-29 04:44:59 -0400 (Tue, 29 Jul 2008)
New Revision: 97
Added:
trunk/src/main/org/jboss/envers/RevisionType.java
trunk/src/main/org/jboss/envers/entity/RevisionTypeType.java
trunk/src/main/org/jboss/envers/query/RevisionTypeProperty.java
Removed:
trunk/src/main/org/jboss/envers/metadata/RevisionType.java
Modified:
trunk/src/main/org/jboss/envers/entity/EntityInstantiator.java
trunk/src/main/org/jboss/envers/metadata/VersionsMetadataGenerator.java
trunk/src/main/org/jboss/envers/query/VersionsQueryCreator.java
trunk/src/main/org/jboss/envers/query/impl/RevisionsOfEntityQuery.java
trunk/src/main/org/jboss/envers/synchronization/work/AbstractVersionsWorkUnit.java
trunk/src/main/org/jboss/envers/synchronization/work/AddWorkUnit.java
trunk/src/main/org/jboss/envers/synchronization/work/CollectionChangeWorkUnit.java
trunk/src/main/org/jboss/envers/synchronization/work/DelWorkUnit.java
trunk/src/main/org/jboss/envers/synchronization/work/ModWorkUnit.java
trunk/src/test/org/jboss/envers/test/integration/query/SimpleQuery.java
Log:
ENVERS-32: revision type returned by the query for revisions
Copied: trunk/src/main/org/jboss/envers/RevisionType.java (from rev 95, trunk/src/main/org/jboss/envers/metadata/RevisionType.java)
===================================================================
--- trunk/src/main/org/jboss/envers/RevisionType.java (rev 0)
+++ trunk/src/main/org/jboss/envers/RevisionType.java 2008-07-29 08:44:59 UTC (rev 97)
@@ -0,0 +1,65 @@
+/*
+ * Envers. http://www.jboss.org/envers
+ *
+ * Copyright 2008 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * 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, v. 2.1.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT A 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, v.2.1 along with this distribution; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ * Red Hat Author(s): Adam Warski
+ */
+package org.jboss.envers;
+
+/**
+ * Type of the revision.
+ * @author Adam Warski (adam at warski dot org)
+ */
+public enum RevisionType {
+ /**
+ * Indicates that the entity was added (persisted) at that revision.
+ */
+ ADD((byte) 0),
+ /**
+ * Indicates that the entity was modified (one or more of its fields) at that revision.
+ */
+ MOD((byte) 1),
+ /**
+ * Indicates that the entity was deleted (removed) at that revision.
+ */
+ DEL((byte) 2);
+
+ private Byte representation;
+
+ RevisionType(byte representation) {
+ this.representation = representation;
+ }
+
+ public Byte getRepresentation() {
+ return representation;
+ }
+
+ public static RevisionType fromRepresentation(Object representation) {
+ if (representation == null || !(representation instanceof Byte)) {
+ return null;
+ }
+
+ switch ((Byte) representation) {
+ case 0: return ADD;
+ case 1: return MOD;
+ case 2: return DEL;
+ }
+
+ throw new IllegalArgumentException("Unknown representation: " + representation);
+ }
+}
Modified: trunk/src/main/org/jboss/envers/entity/EntityInstantiator.java
===================================================================
--- trunk/src/main/org/jboss/envers/entity/EntityInstantiator.java 2008-07-28 15:19:50 UTC (rev 96)
+++ trunk/src/main/org/jboss/envers/entity/EntityInstantiator.java 2008-07-29 08:44:59 UTC (rev 97)
@@ -21,7 +21,7 @@
*/
package org.jboss.envers.entity;
-import org.jboss.envers.metadata.RevisionType;
+import org.jboss.envers.RevisionType;
import org.jboss.envers.exception.VersionsException;
import org.jboss.envers.configuration.VersionsConfiguration;
import org.jboss.envers.mapper.id.IdMapper;
Added: trunk/src/main/org/jboss/envers/entity/RevisionTypeType.java
===================================================================
--- trunk/src/main/org/jboss/envers/entity/RevisionTypeType.java (rev 0)
+++ trunk/src/main/org/jboss/envers/entity/RevisionTypeType.java 2008-07-29 08:44:59 UTC (rev 97)
@@ -0,0 +1,85 @@
+package org.jboss.envers.entity;
+
+import org.hibernate.usertype.UserType;
+import org.hibernate.HibernateException;
+import org.jboss.envers.RevisionType;
+
+import java.sql.ResultSet;
+import java.sql.Types;
+import java.sql.SQLException;
+import java.sql.PreparedStatement;
+import java.io.Serializable;
+
+/**
+ * A hibernate type for the {@link RevisionType} enum.
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class RevisionTypeType implements UserType {
+ private static final int[] SQL_TYPES = { Types.TINYINT };
+
+ public int[] sqlTypes() {
+ return SQL_TYPES;
+ }
+
+ public Class returnedClass() {
+ return RevisionType.class;
+ }
+
+ public RevisionType nullSafeGet(ResultSet resultSet, String[] names, Object owner) throws HibernateException, SQLException {
+ byte representation = (byte) resultSet.getInt(names[0]);
+ RevisionType result = null;
+
+ if (!resultSet.wasNull()) {
+ result = RevisionType.fromRepresentation(representation);
+ }
+
+ return result;
+ }
+
+ public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index) throws HibernateException, SQLException {
+ if (null == value) {
+ preparedStatement.setNull(index, Types.TINYINT);
+ } else {
+ preparedStatement.setInt(index, ((RevisionType) value).getRepresentation());
+ }
+ }
+
+ public Object deepCopy(Object value) throws HibernateException{
+ return value;
+ }
+
+ public boolean isMutable() {
+ return false;
+ }
+
+ public Object assemble(Serializable cached, Object owner) throws HibernateException {
+ return cached;
+ }
+
+ public Serializable disassemble(Object value) throws HibernateException {
+ return (Serializable)value;
+ }
+
+ public Object replace(Object original, Object target, Object owner) throws HibernateException {
+ return original;
+ }
+
+ public int hashCode(Object x) throws HibernateException {
+ return x.hashCode();
+ }
+
+ public boolean equals(Object x, Object y) throws HibernateException {
+ //noinspection ObjectEquality
+ if (x == y) {
+ return true;
+ }
+
+ if (null == x || null == y) {
+ return false;
+ }
+
+ return x.equals(y);
+ }
+}
+
+
Deleted: trunk/src/main/org/jboss/envers/metadata/RevisionType.java
===================================================================
--- trunk/src/main/org/jboss/envers/metadata/RevisionType.java 2008-07-28 15:19:50 UTC (rev 96)
+++ trunk/src/main/org/jboss/envers/metadata/RevisionType.java 2008-07-29 08:44:59 UTC (rev 97)
@@ -1,33 +0,0 @@
-/*
- * Envers. http://www.jboss.org/envers
- *
- * Copyright 2008 Red Hat Middleware, LLC. All rights reserved.
- *
- * 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, v. 2.1.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT A 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, v.2.1 along with this distribution; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- *
- * Red Hat Author(s): Adam Warski
- */
-package org.jboss.envers.metadata;
-
-/**
- * @author Adam Warski (adam at warski dot org)
- */
-public class RevisionType {
- private RevisionType() { }
-
- public final static Byte ADD = 0;
- public final static Byte MOD = 1;
- public final static Byte DEL = 2;
-}
Modified: trunk/src/main/org/jboss/envers/metadata/VersionsMetadataGenerator.java
===================================================================
--- trunk/src/main/org/jboss/envers/metadata/VersionsMetadataGenerator.java 2008-07-28 15:19:50 UTC (rev 96)
+++ trunk/src/main/org/jboss/envers/metadata/VersionsMetadataGenerator.java 2008-07-29 08:44:59 UTC (rev 97)
@@ -558,8 +558,9 @@
class_mapping.add((Element) idMapper.getXmlMapping().clone());
// Adding the "revision type" property
- MetadataTools.addProperty(class_mapping, verEntCfg.getRevisionTypePropName(),
+ Element revTypeProperty = MetadataTools.addProperty(class_mapping, verEntCfg.getRevisionTypePropName(),
verEntCfg.getRevisionTypePropType(), false);
+ revTypeProperty.addAttribute("type", "org.jboss.envers.entity.RevisionTypeType");
break;
case SINGLE:
Copied: trunk/src/main/org/jboss/envers/query/RevisionTypeProperty.java (from rev 95, trunk/src/main/org/jboss/envers/query/RevisionProperty.java)
===================================================================
--- trunk/src/main/org/jboss/envers/query/RevisionTypeProperty.java (rev 0)
+++ trunk/src/main/org/jboss/envers/query/RevisionTypeProperty.java 2008-07-29 08:44:59 UTC (rev 97)
@@ -0,0 +1,46 @@
+/*
+ * Envers. http://www.jboss.org/envers
+ *
+ * Copyright 2008 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * 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, v. 2.1.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT A 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, v.2.1 along with this distribution; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ * Red Hat Author(s): Adam Warski
+ */
+package org.jboss.envers.query;
+
+import org.jboss.envers.query.projection.VersionsProjection;
+import org.jboss.envers.reader.VersionsReaderImplementor;
+import org.hibernate.criterion.Projection;
+import org.hibernate.criterion.Projections;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+@SuppressWarnings({"JavaDoc"})
+public class RevisionTypeProperty implements VersionsProjection {
+ private RevisionTypeProperty() { }
+
+ /**
+ * Select the revision type
+ */
+ public static VersionsProjection revisionType() {
+ return new RevisionTypeProperty();
+ }
+
+ public Projection getProjection(String entityName, VersionsReaderImplementor versionsReader) {
+ return Projections.property(versionsReader.getEntitiesCfg().getRevisionTypePropName());
+ }
+}
\ No newline at end of file
Modified: trunk/src/main/org/jboss/envers/query/VersionsQueryCreator.java
===================================================================
--- trunk/src/main/org/jboss/envers/query/VersionsQueryCreator.java 2008-07-28 15:19:50 UTC (rev 96)
+++ trunk/src/main/org/jboss/envers/query/VersionsQueryCreator.java 2008-07-29 08:44:59 UTC (rev 97)
@@ -52,11 +52,12 @@
}
/**
- * Creates a query, which will return a list of two-element arrays, containing the entity instance and the number
- * of the revision (unless a projection is set), at which instances of the given entity were modified, and which
- * satisfy some conditions.
+ * Creates a query, which will return a list of three-element arrays, containing the entity instance, the number
+ * of the revision (unless a projection is set), at which instances of the given entity were modified, and the type
+ * of the revision ({@link org.jboss.envers.RevisionType}). Additional conditions that the results must satisfy
+ * may be specified.
* @param c Class of the entities for which to query.
- * @param selectEntitiesOnly If true, instead of a list of two-element arrays, a list of entites will be
+ * @param selectEntitiesOnly If true, instead of a list of three-element arrays, a list of entites will be
* returned as a result of executing this query.
* @return A query for revisions at which instances of the given entity were modified, to which
* conditions can be added (for example - a specific id of an entity of class <code>c</code>), and which
Modified: trunk/src/main/org/jboss/envers/query/impl/RevisionsOfEntityQuery.java
===================================================================
--- trunk/src/main/org/jboss/envers/query/impl/RevisionsOfEntityQuery.java 2008-07-28 15:19:50 UTC (rev 96)
+++ trunk/src/main/org/jboss/envers/query/impl/RevisionsOfEntityQuery.java 2008-07-29 08:44:59 UTC (rev 97)
@@ -24,6 +24,7 @@
import org.jboss.envers.exception.VersionsException;
import org.jboss.envers.reader.VersionsReaderImplementor;
import org.jboss.envers.query.criteria.VersionsCriterion;
+import org.jboss.envers.RevisionType;
import org.hibernate.criterion.Order;
import java.util.List;
@@ -68,13 +69,15 @@
List entities = new ArrayList();
String originalId = versionsReader.getEntitiesCfg().getOriginalIdPropName();
String revisionPropertyName = versionsReader.getEntitiesCfg().getRevisionPropName();
+ String revisionTypePropertyName = versionsReader.getEntitiesCfg().getRevisionTypePropName();
for (Map versionsEntity : queryResult) {
Number revision = (Number) ((Map) versionsEntity.get(originalId)).get(revisionPropertyName);
+
Object entity = entityInstantiator.createInstanceFromVersionsEntity(entityName, versionsEntity, revision);
if (!selectEntitiesOnly) {
- entities.add(new Object[] { entity, revision });
+ entities.add(new Object[] { entity, revision, versionsEntity.get(revisionTypePropertyName) });
} else {
entities.add(entity);
}
Modified: trunk/src/main/org/jboss/envers/synchronization/work/AbstractVersionsWorkUnit.java
===================================================================
--- trunk/src/main/org/jboss/envers/synchronization/work/AbstractVersionsWorkUnit.java 2008-07-28 15:19:50 UTC (rev 96)
+++ trunk/src/main/org/jboss/envers/synchronization/work/AbstractVersionsWorkUnit.java 2008-07-29 08:44:59 UTC (rev 97)
@@ -23,6 +23,7 @@
import org.jboss.envers.configuration.VersionsEntitiesConfiguration;
import org.jboss.envers.configuration.VersionsConfiguration;
+import org.jboss.envers.RevisionType;
import org.hibernate.Session;
import java.util.Map;
@@ -45,7 +46,7 @@
this.entityName = entityName;
}
- protected void fillDataWithId(Map<String, Object> data, Number revision, Byte revisionType) {
+ protected void fillDataWithId(Map<String, Object> data, Number revision, RevisionType revisionType) {
VersionsEntitiesConfiguration entitiesCfg = verCfg.getEntitiesCfg();
Map<String, Object> originalId = new HashMap<String, Object>();
Modified: trunk/src/main/org/jboss/envers/synchronization/work/AddWorkUnit.java
===================================================================
--- trunk/src/main/org/jboss/envers/synchronization/work/AddWorkUnit.java 2008-07-28 15:19:50 UTC (rev 96)
+++ trunk/src/main/org/jboss/envers/synchronization/work/AddWorkUnit.java 2008-07-29 08:44:59 UTC (rev 97)
@@ -22,7 +22,7 @@
package org.jboss.envers.synchronization.work;
import org.jboss.envers.configuration.VersionsConfiguration;
-import org.jboss.envers.metadata.RevisionType;
+import org.jboss.envers.RevisionType;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.Session;
Modified: trunk/src/main/org/jboss/envers/synchronization/work/CollectionChangeWorkUnit.java
===================================================================
--- trunk/src/main/org/jboss/envers/synchronization/work/CollectionChangeWorkUnit.java 2008-07-28 15:19:50 UTC (rev 96)
+++ trunk/src/main/org/jboss/envers/synchronization/work/CollectionChangeWorkUnit.java 2008-07-29 08:44:59 UTC (rev 97)
@@ -23,7 +23,7 @@
import org.hibernate.Session;
import org.jboss.envers.configuration.VersionsConfiguration;
-import org.jboss.envers.metadata.RevisionType;
+import org.jboss.envers.RevisionType;
import java.io.Serializable;
import java.util.Map;
Modified: trunk/src/main/org/jboss/envers/synchronization/work/DelWorkUnit.java
===================================================================
--- trunk/src/main/org/jboss/envers/synchronization/work/DelWorkUnit.java 2008-07-28 15:19:50 UTC (rev 96)
+++ trunk/src/main/org/jboss/envers/synchronization/work/DelWorkUnit.java 2008-07-29 08:44:59 UTC (rev 97)
@@ -22,7 +22,7 @@
package org.jboss.envers.synchronization.work;
import org.jboss.envers.configuration.VersionsConfiguration;
-import org.jboss.envers.metadata.RevisionType;
+import org.jboss.envers.RevisionType;
import org.hibernate.Session;
import java.io.Serializable;
Modified: trunk/src/main/org/jboss/envers/synchronization/work/ModWorkUnit.java
===================================================================
--- trunk/src/main/org/jboss/envers/synchronization/work/ModWorkUnit.java 2008-07-28 15:19:50 UTC (rev 96)
+++ trunk/src/main/org/jboss/envers/synchronization/work/ModWorkUnit.java 2008-07-29 08:44:59 UTC (rev 97)
@@ -22,7 +22,7 @@
package org.jboss.envers.synchronization.work;
import org.jboss.envers.configuration.VersionsConfiguration;
-import org.jboss.envers.metadata.RevisionType;
+import org.jboss.envers.RevisionType;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.Session;
Modified: trunk/src/test/org/jboss/envers/test/integration/query/SimpleQuery.java
===================================================================
--- trunk/src/test/org/jboss/envers/test/integration/query/SimpleQuery.java 2008-07-28 15:19:50 UTC (rev 96)
+++ trunk/src/test/org/jboss/envers/test/integration/query/SimpleQuery.java 2008-07-29 08:44:59 UTC (rev 97)
@@ -5,6 +5,8 @@
import org.jboss.envers.test.tools.TestTools;
import org.jboss.envers.query.VersionsRestrictions;
import org.jboss.envers.query.RevisionProperty;
+import org.jboss.envers.query.RevisionTypeProperty;
+import org.jboss.envers.RevisionType;
import org.hibernate.ejb.Ejb3Configuration;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -66,6 +68,15 @@
site3.setStr1("a");
em.getTransaction().commit();
+
+ // Revision 4
+ em.getTransaction().begin();
+
+ site1 = em.find(StrIntTestEntity.class, id1);
+
+ em.remove(site1);
+
+ em.getTransaction().commit();
}
@Test
@@ -175,8 +186,27 @@
assert ((Object []) result.get(0))[0].equals(new StrIntTestEntity("a", 10, id1));
assert ((Object []) result.get(1))[0].equals(new StrIntTestEntity("c", 10, id1));
+ assert ((Object []) result.get(2))[0] == null;
assert ((Object []) result.get(0))[1].equals(1);
assert ((Object []) result.get(1))[1].equals(2);
+ assert ((Object []) result.get(2))[1].equals(4);
+
+ assert ((Object []) result.get(0))[2].equals(RevisionType.ADD);
+ assert ((Object []) result.get(1))[2].equals(RevisionType.MOD);
+ assert ((Object []) result.get(2))[2].equals(RevisionType.DEL);
}
+
+ @Test
+ public void testSelectRevisionTypeQuery() {
+ List result = getVersionsReader().createQuery()
+ .forRevisionsOfEntity(StrIntTestEntity.class, false)
+ .setProjection(RevisionTypeProperty.revisionType())
+ .add(VersionsRestrictions.idEq(id1))
+ .getResultList();
+
+ assert result.get(0).equals(RevisionType.ADD);
+ assert result.get(1).equals(RevisionType.MOD);
+ assert result.get(2).equals(RevisionType.DEL);
+ }
}
16 years, 3 months
JBoss Envers SVN: r96 - in trunk/src: test/org/jboss/envers/test/integration/inheritance/single and 1 other directories.
by jboss-envers-commits@lists.jboss.org
Author: adamw
Date: 2008-07-28 11:19:50 -0400 (Mon, 28 Jul 2008)
New Revision: 96
Added:
trunk/src/test/org/jboss/envers/test/integration/inheritance/single/childrelation/
trunk/src/test/org/jboss/envers/test/integration/inheritance/single/childrelation/ChildIngEntity.java
trunk/src/test/org/jboss/envers/test/integration/inheritance/single/childrelation/ChildReferencing.java
trunk/src/test/org/jboss/envers/test/integration/inheritance/single/childrelation/ParentNotIngEntity.java
trunk/src/test/org/jboss/envers/test/integration/inheritance/single/childrelation/ReferencedEntity.java
Modified:
trunk/src/main/org/jboss/envers/metadata/VersionsMetadataGenerator.java
Log:
ENVERS-29: bug fix with test
Modified: trunk/src/main/org/jboss/envers/metadata/VersionsMetadataGenerator.java
===================================================================
--- trunk/src/main/org/jboss/envers/metadata/VersionsMetadataGenerator.java 2008-07-16 09:40:37 UTC (rev 95)
+++ trunk/src/main/org/jboss/envers/metadata/VersionsMetadataGenerator.java 2008-07-28 15:19:50 UTC (rev 96)
@@ -609,7 +609,12 @@
CompositeMapperBuilder propertyMapper = entitiesConfigurations.get(entityName).getPropertyMapper();
// Mapping unjoined properties
- addProperties(document.getRootElement().element("class"), (Iterator<Property>) pc.getUnjoinedPropertyIterator(),
+ Element parent = document.getRootElement().element("class");
+ if (parent == null) {
+ parent = document.getRootElement().element("subclass");
+ }
+
+ addProperties(parent, (Iterator<Property>) pc.getUnjoinedPropertyIterator(),
propertyMapper, versioningData.propertyStoreInfo, entityName, false);
// Mapping joins (second pass)
Copied: trunk/src/test/org/jboss/envers/test/integration/inheritance/single/childrelation/ChildIngEntity.java (from rev 95, trunk/src/test/org/jboss/envers/test/integration/inheritance/single/relation/ChildIngEntity.java)
===================================================================
--- trunk/src/test/org/jboss/envers/test/integration/inheritance/single/childrelation/ChildIngEntity.java (rev 0)
+++ trunk/src/test/org/jboss/envers/test/integration/inheritance/single/childrelation/ChildIngEntity.java 2008-07-28 15:19:50 UTC (rev 96)
@@ -0,0 +1,70 @@
+package org.jboss.envers.test.integration.inheritance.single.childrelation;
+
+import org.jboss.envers.Versioned;
+
+import javax.persistence.*;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+@Entity
+@DiscriminatorValue("2")
+@Versioned
+public class ChildIngEntity extends ParentNotIngEntity {
+ @Basic
+ private Long number;
+
+ @ManyToOne
+ private ReferencedEntity referenced;
+
+ public ChildIngEntity() {
+ }
+
+ public ChildIngEntity(String data, Long number) {
+ super(data);
+ this.number = number;
+ }
+
+ 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
Copied: trunk/src/test/org/jboss/envers/test/integration/inheritance/single/childrelation/ChildReferencing.java (from rev 95, trunk/src/test/org/jboss/envers/test/integration/inheritance/single/relation/PolymorphicCollection.java)
===================================================================
--- trunk/src/test/org/jboss/envers/test/integration/inheritance/single/childrelation/ChildReferencing.java (rev 0)
+++ trunk/src/test/org/jboss/envers/test/integration/inheritance/single/childrelation/ChildReferencing.java 2008-07-28 15:19:50 UTC (rev 96)
@@ -0,0 +1,98 @@
+package org.jboss.envers.test.integration.inheritance.single.childrelation;
+
+import org.hibernate.ejb.Ejb3Configuration;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+import org.jboss.envers.test.integration.AbstractEntityTest;
+import org.jboss.envers.test.tools.TestTools;
+
+import javax.persistence.EntityManager;
+import java.util.Arrays;
+
+/**
+ * @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();
+
+ // Rev 1
+ em.getTransaction().begin();
+
+ ReferencedEntity re1 = new ReferencedEntity();
+ em.persist(re1);
+ re_id1 = re1.getId();
+
+ ReferencedEntity re2 = new ReferencedEntity();
+ em.persist(re2);
+ re_id2 = re2.getId();
+
+ em.getTransaction().commit();
+
+ // Rev 2
+ em.getTransaction().begin();
+
+ re1 = em.find(ReferencedEntity.class, re_id1);
+
+ ChildIngEntity cie = new ChildIngEntity("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);
+
+ System.out.println(re2.getId());
+ cie.setReferenced(re2);
+
+ em.getTransaction().commit();
+ }
+
+ @Test
+ public void testRevisionsCounts() {
+ assert Arrays.asList(1, 2, 3).equals(getVersionsReader().getRevisions(ReferencedEntity.class, re_id1));
+ assert Arrays.asList(1, 3).equals(getVersionsReader().getRevisions(ReferencedEntity.class, re_id2));
+ assert Arrays.asList(2, 3).equals(getVersionsReader().getRevisions(ChildIngEntity.class, c_id));
+ }
+
+ @Test
+ public void testHistoryOfReferencedCollection1() {
+ assert getVersionsReader().find(ReferencedEntity.class, re_id1, 1).getReferencing().size() == 0;
+ assert getVersionsReader().find(ReferencedEntity.class, re_id1, 2).getReferencing().equals(
+ TestTools.makeSet(new ChildIngEntity(c_id, "y", 1l)));
+ assert getVersionsReader().find(ReferencedEntity.class, re_id1, 3).getReferencing().size() == 0;
+ }
+
+ @Test
+ public void testHistoryOfReferencedCollection2() {
+ assert getVersionsReader().find(ReferencedEntity.class, re_id2, 1).getReferencing().size() == 0;
+ assert getVersionsReader().find(ReferencedEntity.class, re_id2, 2).getReferencing().size() == 0;
+ assert getVersionsReader().find(ReferencedEntity.class, re_id2, 3).getReferencing().equals(
+ TestTools.makeSet(new ChildIngEntity(c_id, "y", 1l)));
+ }
+
+ @Test
+ public void testChildHistory() {
+ assert getVersionsReader().find(ChildIngEntity.class, c_id, 1) == null;
+ assert getVersionsReader().find(ChildIngEntity.class, c_id, 2).getReferenced().equals(
+ new ReferencedEntity(re_id1));
+ assert getVersionsReader().find(ChildIngEntity.class, c_id, 3).getReferenced().equals(
+ new ReferencedEntity(re_id2));
+ }
+}
\ No newline at end of file
Copied: trunk/src/test/org/jboss/envers/test/integration/inheritance/single/childrelation/ParentNotIngEntity.java (from rev 95, trunk/src/test/org/jboss/envers/test/integration/inheritance/single/relation/ParentIngEntity.java)
===================================================================
--- trunk/src/test/org/jboss/envers/test/integration/inheritance/single/childrelation/ParentNotIngEntity.java (rev 0)
+++ trunk/src/test/org/jboss/envers/test/integration/inheritance/single/childrelation/ParentNotIngEntity.java 2008-07-28 15:19:50 UTC (rev 96)
@@ -0,0 +1,73 @@
+package org.jboss.envers.test.integration.inheritance.single.childrelation;
+
+import org.jboss.envers.Versioned;
+
+import javax.persistence.*;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+@Entity
+@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
+@DiscriminatorColumn(name = "discriminator", discriminatorType = DiscriminatorType.INTEGER)
+@DiscriminatorValue("1")
+@Versioned
+public class ParentNotIngEntity {
+ @Id
+ @GeneratedValue
+ private Integer id;
+
+ @Basic
+ private String data;
+
+ public ParentNotIngEntity() {
+ }
+
+ public ParentNotIngEntity(String data) {
+ this.data = data;
+ }
+
+ 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
Copied: trunk/src/test/org/jboss/envers/test/integration/inheritance/single/childrelation/ReferencedEntity.java (from rev 95, trunk/src/test/org/jboss/envers/test/integration/inheritance/single/relation/ReferencedEntity.java)
===================================================================
--- trunk/src/test/org/jboss/envers/test/integration/inheritance/single/childrelation/ReferencedEntity.java (rev 0)
+++ trunk/src/test/org/jboss/envers/test/integration/inheritance/single/childrelation/ReferencedEntity.java 2008-07-28 15:19:50 UTC (rev 96)
@@ -0,0 +1,61 @@
+package org.jboss.envers.test.integration.inheritance.single.childrelation;
+
+import org.jboss.envers.Versioned;
+
+import javax.persistence.Entity;
+import javax.persistence.OneToMany;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+import java.util.Set;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+@Entity
+@Versioned
+public class ReferencedEntity {
+ @Id
+ @GeneratedValue
+ 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;
+ }
+}
\ No newline at end of file
16 years, 3 months
JBoss Envers SVN: r95 - tags.
by jboss-envers-commits@lists.jboss.org
Author: adamw
Date: 2008-07-16 05:40:37 -0400 (Wed, 16 Jul 2008)
New Revision: 95
Added:
tags/1.0.0-ga/
Log:
Taggin the 1.0.0.GA release
Copied: tags/1.0.0-ga (from rev 94, trunk)
16 years, 3 months
JBoss Envers SVN: r94 - trunk.
by jboss-envers-commits@lists.jboss.org
Author: adamw
Date: 2008-07-16 05:38:13 -0400 (Wed, 16 Jul 2008)
New Revision: 94
Modified:
trunk/build.xml
Log:
Source code package now zips to a directory
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2008-07-16 07:32:13 UTC (rev 93)
+++ trunk/build.xml 2008-07-16 09:38:13 UTC (rev 94)
@@ -3,7 +3,7 @@
<!-- Properties -->
<property name="project.name" value="envers"/>
- <property name="project.version" value="preview-dev"/>
+ <property name="project.version" value="1.0.0.ga"/>
<property name="hibernate.32.version" value=""/>
<property name="hibernate.33.version" value="-hibernate-3.3"/>
@@ -277,12 +277,12 @@
<target name="dist-src">
<delete file="${dist.dir}/${dist.src.name}" />
<zip destfile="${dist.dir}/${dist.src.name}">
- <fileset dir=".">
+ <zipfileset dir="." prefix="${project.name}-${project.version}">
<include name="build.xml" />
<include name="${src.dir}/**/*" />
<include name="${resources.dir}/**/*" />
<include name="lib/**/*" />
- </fileset>
+ </zipfileset>
</zip>
</target>
16 years, 3 months
JBoss Envers SVN: r93 - in demos/seam: lib and 1 other directory.
by jboss-envers-commits@lists.jboss.org
Author: adamw
Date: 2008-07-16 03:32:13 -0400 (Wed, 16 Jul 2008)
New Revision: 93
Added:
demos/seam/lib/envers-1.0.0.ga.jar
Removed:
demos/seam/lib/envers-preview-dev.jar
Modified:
demos/seam/
Log:
New Envers lib
Property changes on: demos/seam
___________________________________________________________________
Name: svn:ignore
- *.iml
+ dist
demo
exploded-archives
*.iml
Added: demos/seam/lib/envers-1.0.0.ga.jar
===================================================================
(Binary files differ)
Property changes on: demos/seam/lib/envers-1.0.0.ga.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: demos/seam/lib/envers-preview-dev.jar
===================================================================
(Binary files differ)
16 years, 3 months
JBoss Envers SVN: r92 - trunk/src/test/org/jboss/envers/test/working.
by jboss-envers-commits@lists.jboss.org
Author: adamw
Date: 2008-07-16 03:25:27 -0400 (Wed, 16 Jul 2008)
New Revision: 92
Modified:
trunk/src/test/org/jboss/envers/test/working/WorkingEntity1.java
trunk/src/test/org/jboss/envers/test/working/WorkingEntity2.java
trunk/src/test/org/jboss/envers/test/working/WorkingMain.java
Log:
Cleanup
Modified: trunk/src/test/org/jboss/envers/test/working/WorkingEntity1.java
===================================================================
--- trunk/src/test/org/jboss/envers/test/working/WorkingEntity1.java 2008-07-16 07:22:43 UTC (rev 91)
+++ trunk/src/test/org/jboss/envers/test/working/WorkingEntity1.java 2008-07-16 07:25:27 UTC (rev 92)
@@ -25,10 +25,10 @@
//@Column(table = "second_table", name = "cc_second")
private String cc;
- //@Versioned
+ @Versioned
//@OneToOne
- //@ManyToOne
- @Transient
+ @ManyToOne
+ //@Transient
private WorkingEntity2 we2;
public WorkingEntity1() {
Modified: trunk/src/test/org/jboss/envers/test/working/WorkingEntity2.java
===================================================================
--- trunk/src/test/org/jboss/envers/test/working/WorkingEntity2.java 2008-07-16 07:22:43 UTC (rev 91)
+++ trunk/src/test/org/jboss/envers/test/working/WorkingEntity2.java 2008-07-16 07:25:27 UTC (rev 92)
@@ -21,8 +21,8 @@
private String str2;
@Versioned
- //@OneToMany(mappedBy = "we2")
- @ManyToMany
+ @OneToMany(mappedBy = "we2")
+ //@ManyToMany
//@Transient
private Set<WorkingEntity1> we1s;
Modified: trunk/src/test/org/jboss/envers/test/working/WorkingMain.java
===================================================================
--- trunk/src/test/org/jboss/envers/test/working/WorkingMain.java 2008-07-16 07:22:43 UTC (rev 91)
+++ trunk/src/test/org/jboss/envers/test/working/WorkingMain.java 2008-07-16 07:25:27 UTC (rev 92)
@@ -20,10 +20,7 @@
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.HashSet;
+import java.util.*;
/**
* @author Adam Warski (adam at warski dot org)
@@ -60,58 +57,9 @@
// Rev 1
entityManager.getTransaction().begin();
- WorkingEntity2 we2 = new WorkingEntity2();
- entityManager.persist(we2);
- entityManager.getTransaction().commit();
- // Rev 2
- entityManager.getTransaction().begin();
-
- we2 = entityManager.find(WorkingEntity2.class, we2.getId2());
-
- WorkingEntity1 we1 = new WorkingEntity1();
- we1.setWe2(we2);
- entityManager.persist(we1);
-
- entityManager.getTransaction().commit();
-
- /*
- // Rev 2
- entityManager.getTransaction().begin();
-
- se1 = entityManager.find(SubEntity.class, se1.getId());
- se1.setData("y");
- se1.setNumber(20l);
-
- entityManager.getTransaction().commit();
-
- // Test
- VersionsReader vr = VersionsReaderFactory.get(entityManager);*/
- //System.out.println(vr.find(SubEntity.class, se1.getId(), 1));
-
- /*
- cfg.addResource("org/jboss/envers/test/working/test.hbm.xml");
- Session session = getSession(entityManager);
-
- session.getTransaction().begin();
-
- Map test1 = new HashMap();
- test1.put("dataA", "a");
- session.persist("Superclass", test1);
-
- Map test2 = new HashMap();
- test2.put("dataB", "b");
- session.persist("Subclass", test2);
-
- session.getTransaction().commit();
-
- session.getTransaction().begin();
-
- System.out.println(session.createQuery("select s from Superclass s").list());
- System.out.println(session.createQuery("select s from Subclass s").list());
-
- session.getTransaction().commit(); */
+ entityManager.getTransaction().commit();
}
}
16 years, 3 months
JBoss Envers SVN: r91 - in trunk: src/main/org/jboss/envers/entity and 1 other directories.
by jboss-envers-commits@lists.jboss.org
Author: adamw
Date: 2008-07-16 03:22:43 -0400 (Wed, 16 Jul 2008)
New Revision: 91
Modified:
trunk/build.xml
trunk/src/main/org/jboss/envers/entity/EntityInstantiator.java
trunk/src/main/org/jboss/envers/query/impl/EntitiesAtRevisionQuery.java
trunk/src/main/org/jboss/envers/query/impl/RevisionsOfEntityQuery.java
Log:
Fixing a bug with using JPA, not Hibernate (then, the $type$ property isn't always present)
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2008-07-04 07:04:46 UTC (rev 90)
+++ trunk/build.xml 2008-07-16 07:22:43 UTC (rev 91)
@@ -10,7 +10,7 @@
<property name="dist.jar.32.name" value="${project.name}-${project.version}${hibernate.32.version}.jar" />
<property name="dist.jar.33.name" value="${project.name}-${project.version}${hibernate.33.version}.jar" />
- <property name="dist.demo.name" value="${project.name}-${project.version}-demo.jar" />
+ <property name="dist.demo.name" value="${project.name}-console-demo.jar" />
<property name="dist.src.name" value="${project.name}-${project.version}-src.zip" />
<property name="dist.dir" value="dist" />
Modified: trunk/src/main/org/jboss/envers/entity/EntityInstantiator.java
===================================================================
--- trunk/src/main/org/jboss/envers/entity/EntityInstantiator.java 2008-07-04 07:04:46 UTC (rev 90)
+++ trunk/src/main/org/jboss/envers/entity/EntityInstantiator.java 2008-07-16 07:22:43 UTC (rev 91)
@@ -46,12 +46,13 @@
/**
* Creates an entity instance based on an entry from the versions table.
+ * @param entityName Name of the entity, which instances should be read
* @param versionsEntity An entry in the versions table, from which data should be mapped.
* @param revision Revision at which this entity was read.
* @return An entity instance, with versioned properties set as in the versionsEntity map, and proxies
* created for collections.
*/
- public Object createInstanceFromVersionsEntity(Map versionsEntity, Number revision) {
+ public Object createInstanceFromVersionsEntity(String entityName, Map versionsEntity, Number revision) {
if (versionsEntity == null) {
return null;
}
@@ -62,10 +63,14 @@
}
// The $type$ property holds the name of the (versions) entity
- String entityName = verCfg.getEntityNameForVersionsEntityName((String) versionsEntity.get("$type$"));
+ String type = verCfg.getEntityNameForVersionsEntityName((String) versionsEntity.get("$type$"));
+ if (type != null) {
+ entityName = type;
+ }
+
Object ret;
- try {
+ try {
Class<?> cls = ReflectionTools.loadClass(entityName);
ret = cls.newInstance();
} catch (Exception e) {
@@ -84,9 +89,9 @@
}
@SuppressWarnings({"unchecked"})
- public void addInstancesFromVersionsEntities(List list, List<Map> versionsEntities, Number revision) {
+ public void addInstancesFromVersionsEntities(String entityName, List list, List<Map> versionsEntities, Number revision) {
for (Map versionsEntity : versionsEntities) {
- list.add(createInstanceFromVersionsEntity(versionsEntity, revision));
+ list.add(createInstanceFromVersionsEntity(entityName, versionsEntity, revision));
}
}
}
Modified: trunk/src/main/org/jboss/envers/query/impl/EntitiesAtRevisionQuery.java
===================================================================
--- trunk/src/main/org/jboss/envers/query/impl/EntitiesAtRevisionQuery.java 2008-07-04 07:04:46 UTC (rev 90)
+++ trunk/src/main/org/jboss/envers/query/impl/EntitiesAtRevisionQuery.java 2008-07-16 07:22:43 UTC (rev 91)
@@ -75,7 +75,7 @@
return queryResult;
} else {
List result = new ArrayList();
- entityInstantiator.addInstancesFromVersionsEntities(result, queryResult, revision);
+ entityInstantiator.addInstancesFromVersionsEntities(entityName, result, queryResult, revision);
return result;
}
Modified: trunk/src/main/org/jboss/envers/query/impl/RevisionsOfEntityQuery.java
===================================================================
--- trunk/src/main/org/jboss/envers/query/impl/RevisionsOfEntityQuery.java 2008-07-04 07:04:46 UTC (rev 90)
+++ trunk/src/main/org/jboss/envers/query/impl/RevisionsOfEntityQuery.java 2008-07-16 07:22:43 UTC (rev 91)
@@ -71,7 +71,7 @@
for (Map versionsEntity : queryResult) {
Number revision = (Number) ((Map) versionsEntity.get(originalId)).get(revisionPropertyName);
- Object entity = entityInstantiator.createInstanceFromVersionsEntity(versionsEntity, revision);
+ Object entity = entityInstantiator.createInstanceFromVersionsEntity(entityName, versionsEntity, revision);
if (!selectEntitiesOnly) {
entities.add(new Object[] { entity, revision });
16 years, 3 months
JBoss Envers SVN: r90 - trunk/src/main/org/jboss/envers/event.
by jboss-envers-commits@lists.jboss.org
Author: adamw
Date: 2008-07-04 03:04:46 -0400 (Fri, 04 Jul 2008)
New Revision: 90
Modified:
trunk/src/main/org/jboss/envers/event/VersionsEventListener.java
Log:
Fixing a bug with generating collection revisions - only the owning side is checked
Modified: trunk/src/main/org/jboss/envers/event/VersionsEventListener.java
===================================================================
--- trunk/src/main/org/jboss/envers/event/VersionsEventListener.java 2008-07-03 11:36:38 UTC (rev 89)
+++ trunk/src/main/org/jboss/envers/event/VersionsEventListener.java 2008-07-04 07:04:46 UTC (rev 90)
@@ -58,7 +58,7 @@
for (int i=0; i<propertyNames.length; i++) {
String propertyName = propertyNames[i];
RelationDescription relDesc = verCfg.getRelationDescription(entityName, propertyName);
- if (relDesc != null && relDesc.bidirectional) {
+ if (relDesc != null && relDesc.bidirectional && relDesc.relationType == RelationDescription.RelationType.TO_ONE) {
// Checking for changes
Object oldValue = oldState == null ? null : oldState[i];
Object newValue = newState == null ? null : newState[i];
16 years, 4 months
JBoss Envers SVN: r89 - trunk/src/main/org/jboss/envers/entity.
by jboss-envers-commits@lists.jboss.org
Author: adamw
Date: 2008-07-03 07:36:38 -0400 (Thu, 03 Jul 2008)
New Revision: 89
Removed:
trunk/src/main/org/jboss/envers/entity/VersionsInheritanceEntityPersister.java
Log:
ENVERS-27: separating builds for hibernate 3.2 and 3.3
Deleted: trunk/src/main/org/jboss/envers/entity/VersionsInheritanceEntityPersister.java
===================================================================
--- trunk/src/main/org/jboss/envers/entity/VersionsInheritanceEntityPersister.java 2008-07-03 11:35:48 UTC (rev 88)
+++ trunk/src/main/org/jboss/envers/entity/VersionsInheritanceEntityPersister.java 2008-07-03 11:36:38 UTC (rev 89)
@@ -1,45 +0,0 @@
-/*
- * Envers. http://www.jboss.org/envers
- *
- * Copyright 2008 Red Hat Middleware, LLC. All rights reserved.
- *
- * 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, v. 2.1.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT A 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, v.2.1 along with this distribution; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- *
- * Red Hat Author(s): Adam Warski
- */
-package org.jboss.envers.entity;
-
-import org.hibernate.persister.entity.SingleTableEntityPersister;
-import org.hibernate.persister.entity.EntityPersister;
-import org.hibernate.mapping.PersistentClass;
-import org.hibernate.cache.CacheConcurrencyStrategy;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.engine.Mapping;
-import org.hibernate.HibernateException;
-import org.hibernate.EntityMode;
-
-/**
- * @author Adam Warski (adam at warski dot org)
- */
-public class VersionsInheritanceEntityPersister extends SingleTableEntityPersister {
- public VersionsInheritanceEntityPersister(PersistentClass persistentClass, CacheConcurrencyStrategy cache, SessionFactoryImplementor factory, Mapping mapping) throws HibernateException {
- super(persistentClass, cache, factory, mapping);
- }
-
- // A hack for http://opensource.atlassian.com/projects/hibernate/browse/HHH-3351
- public EntityPersister getSubclassEntityPersister(Object instance, SessionFactoryImplementor factory, EntityMode entityMode) {
- return this;
- }
-}
\ No newline at end of file
16 years, 4 months
JBoss Envers SVN: r88 - in trunk: src and 11 other directories.
by jboss-envers-commits@lists.jboss.org
Author: adamw
Date: 2008-07-03 07:35:48 -0400 (Thu, 03 Jul 2008)
New Revision: 88
Added:
trunk/src/main-3.2/
trunk/src/main-3.2/org/
trunk/src/main-3.2/org/jboss/
trunk/src/main-3.2/org/jboss/envers/
trunk/src/main-3.2/org/jboss/envers/entity/
trunk/src/main-3.2/org/jboss/envers/entity/VersionsInheritanceEntityPersisterFor32.java
trunk/src/main-3.3/org/jboss/envers/entity/VersionsInheritanceEntityPersisterFor33.java
trunk/src/main/org/jboss/envers/log/
trunk/src/main/org/jboss/envers/log/YLog.java
trunk/src/main/org/jboss/envers/log/YLogManager.java
Removed:
trunk/src/main-3.3/org/jboss/envers/entity/VersionsInheritanceEntityPersisterFor330.java
Modified:
trunk/build.xml
trunk/envers.iml
trunk/src/main/org/jboss/envers/configuration/VersionsConfiguration.java
trunk/src/main/org/jboss/envers/metadata/VersionsMetadataGenerator.java
trunk/src/test/org/jboss/envers/test/working/WorkingEntity1.java
trunk/src/test/org/jboss/envers/test/working/WorkingEntity2.java
trunk/src/test/org/jboss/envers/test/working/WorkingMain.java
trunk/src/test/org/jboss/envers/test/working/test.hbm.xml
Log:
ENVERS-27: separate builds for 3.2 and 3.3
Configuration option to suppress excpetions on unsupported types
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2008-06-24 14:06:27 UTC (rev 87)
+++ trunk/build.xml 2008-07-03 11:35:48 UTC (rev 88)
@@ -1,11 +1,15 @@
<?xml version="1.0"?>
-<project name="versioning" default="build" basedir=".">
+<project name="versioning" default="build-32" basedir=".">
<!-- Properties -->
<property name="project.name" value="envers"/>
<property name="project.version" value="preview-dev"/>
- <property name="dist.jar.name" value="${project.name}-${project.version}.jar" />
+ <property name="hibernate.32.version" value=""/>
+ <property name="hibernate.33.version" value="-hibernate-3.3"/>
+
+ <property name="dist.jar.32.name" value="${project.name}-${project.version}${hibernate.32.version}.jar" />
+ <property name="dist.jar.33.name" value="${project.name}-${project.version}${hibernate.33.version}.jar" />
<property name="dist.demo.name" value="${project.name}-${project.version}-demo.jar" />
<property name="dist.src.name" value="${project.name}-${project.version}-src.zip" />
@@ -24,6 +28,7 @@
<property name="src.dir" value="src" />
<property name="src.main.dir" value="${src.dir}/main" />
+ <property name="src.main32.dir" value="${src.dir}/main-3.2" />
<property name="src.main33.dir" value="${src.dir}/main-3.3" />
<property name="src.demo.dir" value="${src.dir}/demo" />
<property name="src.test.dir" value="${src.dir}/test" />
@@ -60,15 +65,19 @@
<path id="build.main.classpath">
<fileset refid="lib.hibernate.common" />
+ </path>
+
+ <path id="build.main32.classpath">
+ <path refid="build.main.classpath" />
<fileset refid="lib.hibernate.326" />
</path>
<path id="build.main33.classpath">
- <fileset refid="lib.hibernate.common" />
+ <path refid="build.main.classpath" />
<fileset refid="lib.hibernate.330" />
</path>
- <path id="build.test.classpath">
+ <path id="build.test32.classpath">
<fileset refid="lib.hibernate.common" />
<fileset refid="lib.hibernate.326" />
<fileset refid="lib.test" />
@@ -85,8 +94,7 @@
<fileset refid="lib.test" />
</path>
- <path id="test.hibernate330.classpath">
- <fileset refid="lib.hibernate.330" />
+ <path id="test.hibernate.classpath.common">
<fileset refid="lib.hibernate.common" />
<fileset refid="lib.test" />
<fileset refid="lib.db" />
@@ -95,24 +103,19 @@
<pathelement path="${build.test.dir}" />
</path>
+ <path id="test.hibernate330.classpath">
+ <fileset refid="lib.hibernate.330" />
+ <path refid="test.hibernate.classpath.common" />
+ </path>
+
<path id="test.hibernate326.classpath">
<fileset refid="lib.hibernate.326" />
- <fileset refid="lib.hibernate.common" />
- <fileset refid="lib.test" />
- <fileset refid="lib.db" />
- <pathelement path="${resources.test.dir}" />
- <pathelement path="${build.main.dir}" />
- <pathelement path="${build.test.dir}" />
+ <path refid="test.hibernate.classpath.common" />
</path>
<path id="test.hibernate324.classpath">
<fileset refid="lib.hibernate.324" />
- <fileset refid="lib.hibernate.common" />
- <fileset refid="lib.test" />
- <fileset refid="lib.db" />
- <pathelement path="${resources.test.dir}" />
- <pathelement path="${build.main.dir}" />
- <pathelement path="${build.test.dir}" />
+ <path refid="test.hibernate.classpath.common" />
</path>
<!-- Clean targets -->
@@ -122,17 +125,32 @@
<delete dir="${dist.dir}" />
</target>
+ <target name="clean-build">
+ <delete dir="${build.dir}" />
+ </target>
+
<!-- Build targets -->
- <target name="build" depends="clean">
+ <target name="build-common" depends="clean-build">
<mkdir dir="${build.main.dir}" />
- <javac classpathref="build.main.classpath"
+ <javac classpathref="build.main32.classpath"
destdir="${build.main.dir}"
debug="true"
nowarn="on">
<src path="${src.main.dir}" />
</javac>
+ </target>
+ <target name="build-32" depends="build-common">
+ <javac classpathref="build.main32.classpath"
+ destdir="${build.main.dir}"
+ debug="true"
+ nowarn="on">
+ <src path="${src.main32.dir}" />
+ </javac>
+ </target>
+
+ <target name="build-33" depends="build-common">
<javac classpathref="build.main33.classpath"
destdir="${build.main.dir}"
debug="true"
@@ -141,9 +159,11 @@
</javac>
</target>
- <target name="build-test" depends="build">
+ <!-- Build tests targets -->
+
+ <target name="build-test-common">
<mkdir dir="${build.test.dir}" />
- <javac classpathref="build.test.classpath"
+ <javac classpathref="build.test32.classpath"
destdir="${build.test.dir}"
debug="true"
nowarn="on">
@@ -151,7 +171,13 @@
</javac>
</target>
- <target name="build-demo" depends="build">
+ <target name="build-test-32" depends="build-32, build-test-common" />
+
+ <target name="build-test-33" depends="build-33, build-test-common" />
+
+ <!-- Build demo targets -->
+
+ <target name="build-demo" depends="build-32">
<mkdir dir="${build.demo.dir}" />
<javac classpathref="build.demo.classpath"
destdir="${build.demo.dir}"
@@ -166,9 +192,9 @@
<!-- Dist targets -->
- <target name="dist" depends="build">
+ <target name="dist-common">
<mkdir dir="${dist.dir}" />
- <jar destfile="${dist.dir}/${dist.jar.name}">
+ <jar destfile="${dist.dir}/${dist.jar.name}" >
<fileset dir="${build.main.dir}" />
<fileset dir="${resources.main.dir}" />
<manifest>
@@ -184,7 +210,19 @@
</jar>
</target>
- <target name="dist-demo" depends="build-demo,dist">
+ <target name="dist-32">
+ <property name="dist.jar.name" value="${dist.jar.32.name}" />
+ <ant target="build-32" />
+ <ant target="dist-common" />
+ </target>
+
+ <target name="dist-33">
+ <property name="dist.jar.name" value="${dist.jar.33.name}" />
+ <ant target="build-33" />
+ <ant target="dist-common" />
+ </target>
+
+ <target name="dist-demo" depends="dist-32, build-demo">
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask"
classpath="lib/ant/jarjar-1.0rc7.jar"/>
@@ -252,7 +290,7 @@
<taskdef resource="testngtasks" classpathref="testng.classpath" />
- <target name="test-hibernate-330" depends="build-test">
+ <target name="test-hibernate-330" depends="build-test-33">
<delete dir="${test.output.dir}" />
<testng classpathref="test.hibernate330.classpath"
outputDir="${test.output.dir}">
@@ -260,7 +298,7 @@
</testng>
</target>
- <target name="test-hibernate-326" depends="build-test">
+ <target name="test-hibernate-326" depends="build-test-32">
<delete dir="${test.output.dir}" />
<testng classpathref="test.hibernate326.classpath"
outputDir="${test.output.dir}">
@@ -268,7 +306,7 @@
</testng>
</target>
- <target name="test-hibernate-324" depends="build-test">
+ <target name="test-hibernate-324" depends="build-test-32">
<delete dir="${test.output.dir}" />
<testng classpathref="test.hibernate324.classpath"
outputDir="${test.output.dir}">
Modified: trunk/envers.iml
===================================================================
--- trunk/envers.iml 2008-06-24 14:06:27 UTC (rev 87)
+++ trunk/envers.iml 2008-07-03 11:35:48 UTC (rev 88)
@@ -7,6 +7,7 @@
<sourceFolder url="file://$MODULE_DIR$/resources/test" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/demo" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/main-3.2" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build" />
</content>
Modified: trunk/src/main/org/jboss/envers/configuration/VersionsConfiguration.java
===================================================================
--- trunk/src/main/org/jboss/envers/configuration/VersionsConfiguration.java 2008-06-24 14:06:27 UTC (rev 87)
+++ trunk/src/main/org/jboss/envers/configuration/VersionsConfiguration.java 2008-07-03 11:35:48 UTC (rev 88)
@@ -56,6 +56,9 @@
// Should a revision be generated when a not-owned relation field changes
private boolean generateRevisionsForCollections;
+ // Should a warning, instead of an error and an exception, be logged, when an unsupported type is versioned
+ private boolean warnOnUnsupportedTypes;
+
//
public VersionsEntitiesConfiguration getEntitiesCfg() {
@@ -103,6 +106,10 @@
String generateRevisionsForCollectionsStr = properties.getProperty("org.jboss.envers.revisionOnCollectionChange",
"true");
generateRevisionsForCollections = Boolean.parseBoolean(generateRevisionsForCollectionsStr);
+
+ String warnOnUnsupportedTypesStr = properties.getProperty("org.jboss.envers.warnOnUnsupportedTypes",
+ "false");
+ warnOnUnsupportedTypes = Boolean.parseBoolean(warnOnUnsupportedTypesStr);
}
@SuppressWarnings({"unchecked"})
@@ -115,7 +122,7 @@
versionsSyncManager = new VersionsSyncManager(verEntCfg);
- VersionsMetadataGenerator versionsMetaGen = new VersionsMetadataGenerator(verEntCfg);
+ VersionsMetadataGenerator versionsMetaGen = new VersionsMetadataGenerator(this, verEntCfg);
DOMWriter writer = new DOMWriter();
// Sorting the persistent class topologically - superclass always before subclass
@@ -126,11 +133,12 @@
Map<PersistentClass, Document> documents = new HashMap<PersistentClass, Document>();
// First pass
+ AnnotationsMetadataReader annotationsMetadataReader = new AnnotationsMetadataReader();
while (classes.hasNext()) {
PersistentClass pc = classes.next();
// Collecting information from annotations on the persistent class pc
PersistentClassVersioningData versioningData =
- new AnnotationsMetadataReader().getVersioningData(pc, reflectionManager);
+ annotationsMetadataReader.getVersioningData(pc, reflectionManager);
if (isVersioned(versioningData)) {
pcDatas.put(pc, versioningData);
@@ -207,6 +215,10 @@
return generateRevisionsForCollections;
}
+ public boolean isWarnOnUnsupportedTypes() {
+ return warnOnUnsupportedTypes;
+ }
+
public RelationDescription getRelationDescription(String entityName, String propertyName) {
return entitiesConfigurations.getRelationDescription(entityName, propertyName);
}
Added: trunk/src/main/org/jboss/envers/log/YLog.java
===================================================================
--- trunk/src/main/org/jboss/envers/log/YLog.java (rev 0)
+++ trunk/src/main/org/jboss/envers/log/YLog.java 2008-07-03 11:35:48 UTC (rev 88)
@@ -0,0 +1,90 @@
+/*
+ * Envers. http://www.jboss.org/envers
+ *
+ * Copyright 2008 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * 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, v. 2.1.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT A 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, v.2.1 along with this distribution; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ * Red Hat Author(s): Adam Warski
+ */
+package org.jboss.envers.log;
+
+import org.jboss.envers.exception.VersionsException;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * A simple logger facade which delegates through reflection to a logging delegate.
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class YLog {
+ private Object delegate;
+ private Method errorMethod;
+ private Method warnMethod;
+ private Method infoMethod;
+
+ public YLog(Object delegate, Class<?> argClass) {
+ this.delegate = delegate;
+
+ try {
+ errorMethod = delegate.getClass().getMethod("error", argClass);
+ } catch (NoSuchMethodException e) {
+ throw new VersionsException(e);
+ }
+
+ try {
+ warnMethod = delegate.getClass().getMethod("warn", argClass);
+ } catch (NoSuchMethodException e) {
+ throw new VersionsException(e);
+ }
+
+ try {
+ infoMethod = delegate.getClass().getMethod("info", argClass);
+ } catch (NoSuchMethodException e) {
+ throw new VersionsException(e);
+ }
+ }
+
+ public void error(String message) {
+ try {
+ errorMethod.invoke(delegate, message);
+ } catch (IllegalAccessException e) {
+ throw new VersionsException(e);
+ } catch (InvocationTargetException e) {
+ throw new VersionsException(e);
+ }
+ }
+
+ public void warn(String message) {
+ try {
+ warnMethod.invoke(delegate, message);
+ } catch (IllegalAccessException e) {
+ throw new VersionsException(e);
+ } catch (InvocationTargetException e) {
+ throw new VersionsException(e);
+ }
+ }
+
+ public void info(String message) {
+ try {
+ infoMethod.invoke(delegate, message);
+ } catch (IllegalAccessException e) {
+ throw new VersionsException(e);
+ } catch (InvocationTargetException e) {
+ throw new VersionsException(e);
+ }
+ }
+}
Added: trunk/src/main/org/jboss/envers/log/YLogManager.java
===================================================================
--- trunk/src/main/org/jboss/envers/log/YLogManager.java (rev 0)
+++ trunk/src/main/org/jboss/envers/log/YLogManager.java 2008-07-03 11:35:48 UTC (rev 88)
@@ -0,0 +1,90 @@
+/*
+ * Envers. http://www.jboss.org/envers
+ *
+ * Copyright 2008 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * 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, v. 2.1.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT A 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, v.2.1 along with this distribution; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ * Red Hat Author(s): Adam Warski
+ */
+package org.jboss.envers.log;
+
+import org.jboss.envers.exception.VersionsException;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * A class for creating logging facades either to loggers obtained from
+ * <code>org.apache.commons.logging.LogFactory</code> (in Hibernate 3.2.x) or from
+ * <code>org.slf4j.LoggerFactory</code> (in Hibernate 3.3.x).
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class YLogManager {
+ private Method getLogMethod;
+ private Class argClass;
+
+ private YLogManager() {
+ initMethod();
+ }
+
+ private void initMethod() {
+ ClassLoader cl = YLogManager.class.getClassLoader();
+
+ try {
+ Class<?> logFactoryClass = cl.loadClass("org.apache.commons.logging.LogFactory");
+ try {
+ getLogMethod = logFactoryClass.getMethod("getLog", Class.class);
+ argClass = Object.class;
+ } catch (NoSuchMethodException e) {
+ throw new VersionsException("No 'getLog' method in org.apache.commons.logging.LogFactory.");
+ }
+ } catch (ClassNotFoundException e) {
+ try {
+ Class<?> loggerFactoryClass = cl.loadClass("org.slf4j.LoggerFactory");
+ try {
+ getLogMethod = loggerFactoryClass.getMethod("getLogger", Class.class);
+ argClass = String.class;
+ } catch (NoSuchMethodException e1) {
+ throw new VersionsException("No 'getLogger' method in org.slf4j.LoggerFactory.");
+ }
+ } catch (ClassNotFoundException e1) {
+ throw new VersionsException("No org.apache.commons.logging.LogFactory or org.slf4j.LoggerFactory found.");
+ }
+ }
+ }
+
+ public YLog getLog(Class<?> cls) {
+ try {
+ return new YLog(getLogMethod.invoke(null, cls), argClass);
+ } catch (IllegalAccessException e) {
+ throw new VersionsException(e);
+ } catch (InvocationTargetException e) {
+ throw new VersionsException(e);
+ }
+ }
+
+ //
+
+ private static YLogManager instance;
+
+ public static synchronized YLogManager getLogManager() {
+ if (instance == null) {
+ instance = new YLogManager();
+ }
+
+ return instance;
+ }
+}
Modified: trunk/src/main/org/jboss/envers/metadata/VersionsMetadataGenerator.java
===================================================================
--- trunk/src/main/org/jboss/envers/metadata/VersionsMetadataGenerator.java 2008-06-24 14:06:27 UTC (rev 87)
+++ trunk/src/main/org/jboss/envers/metadata/VersionsMetadataGenerator.java 2008-07-03 11:35:48 UTC (rev 88)
@@ -32,6 +32,7 @@
import org.dom4j.tree.DefaultElement;
import org.jboss.envers.configuration.VersionsEntitiesConfiguration;
import org.jboss.envers.configuration.EntityConfiguration;
+import org.jboss.envers.configuration.VersionsConfiguration;
import org.jboss.envers.mapper.*;
import org.jboss.envers.mapper.id.*;
import org.jboss.envers.mapper.id.relation.ToOneIdMapper;
@@ -41,6 +42,8 @@
import org.jboss.envers.tools.Tools;
import org.jboss.envers.tools.HibernateVersion;
import org.jboss.envers.ModificationStore;
+import org.jboss.envers.log.YLog;
+import org.jboss.envers.log.YLogManager;
import org.jboss.envers.metadata.data.IdMappingData;
import org.jboss.envers.metadata.data.PersistentClassVersioningData;
import org.jboss.envers.metadata.data.PropertyStoreInfo;
@@ -57,13 +60,17 @@
public class VersionsMetadataGenerator {
private final static Map<String, ModificationStore> EMPTY_STORE = Collections.emptyMap();
+ private VersionsConfiguration verCfg;
private VersionsEntitiesConfiguration verEntCfg;
private Map<String, EntityConfiguration> entitiesConfigurations;
// Map entity name -> (join descriptor -> element describing the "versioned" join)
private Map<String, Map<Join, Element>> entitiesJoins;
- public VersionsMetadataGenerator(VersionsEntitiesConfiguration verEntCfg) {
+ private YLog log = YLogManager.getLogManager().getLog(VersionsMetadataGenerator.class);
+
+ public VersionsMetadataGenerator(VersionsConfiguration verCfg, VersionsEntitiesConfiguration verEntCfg) {
+ this.verCfg = verCfg;
this.verEntCfg = verEntCfg;
entitiesConfigurations = new HashMap<String, EntityConfiguration>();
@@ -377,13 +384,20 @@
if (firstPass) {
addSimpleProperty(parent, property, currentMapper, store, false);
}
- } else if (propertyType instanceof BagType || propertyType instanceof SetType) {
+ } else if ((propertyType instanceof BagType || propertyType instanceof SetType) &&
+ ((((Collection) property.getValue()).getElement() instanceof OneToMany))) {
// only second pass
if (!firstPass) {
addOneToMany(property, currentMapper, entityName);
}
} else {
- throw new MappingException("Type not supported for versioning: " + propertyType.getClass().getName());
+ String message = "Type not supported for versioning: " + propertyType.getClass().getName() +
+ ", on entity " + entityName + ", property '" + property.getName() + "'.";
+ if (verCfg.isWarnOnUnsupportedTypes()) {
+ log.warn(message);
+ } else {
+ throw new MappingException(message);
+ }
}
}
}
@@ -489,9 +503,9 @@
private void addPersisterHack(Element class_mapping) {
String persisterClassName;
if (HibernateVersion.get().startsWith("3.3")) {
- persisterClassName = "org.jboss.envers.entity.VersionsInheritanceEntityPersisterFor330";
+ persisterClassName = "org.jboss.envers.entity.VersionsInheritanceEntityPersisterFor33";
} else {
- persisterClassName = "org.jboss.envers.entity.VersionsInheritanceEntityPersister";
+ persisterClassName = "org.jboss.envers.entity.VersionsInheritanceEntityPersisterFor32";
}
class_mapping.addAttribute("persister", persisterClassName);
Copied: trunk/src/main-3.2/org/jboss/envers/entity/VersionsInheritanceEntityPersisterFor32.java (from rev 87, trunk/src/main/org/jboss/envers/entity/VersionsInheritanceEntityPersister.java)
===================================================================
--- trunk/src/main-3.2/org/jboss/envers/entity/VersionsInheritanceEntityPersisterFor32.java (rev 0)
+++ trunk/src/main-3.2/org/jboss/envers/entity/VersionsInheritanceEntityPersisterFor32.java 2008-07-03 11:35:48 UTC (rev 88)
@@ -0,0 +1,45 @@
+/*
+ * Envers. http://www.jboss.org/envers
+ *
+ * Copyright 2008 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * 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, v. 2.1.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT A 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, v.2.1 along with this distribution; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ * Red Hat Author(s): Adam Warski
+ */
+package org.jboss.envers.entity;
+
+import org.hibernate.persister.entity.SingleTableEntityPersister;
+import org.hibernate.persister.entity.EntityPersister;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.cache.CacheConcurrencyStrategy;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.engine.Mapping;
+import org.hibernate.HibernateException;
+import org.hibernate.EntityMode;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class VersionsInheritanceEntityPersisterFor32 extends SingleTableEntityPersister {
+ public VersionsInheritanceEntityPersisterFor32(PersistentClass persistentClass, CacheConcurrencyStrategy cache, SessionFactoryImplementor factory, Mapping mapping) throws HibernateException {
+ super(persistentClass, cache, factory, mapping);
+ }
+
+ // A hack for http://opensource.atlassian.com/projects/hibernate/browse/HHH-3351
+ public EntityPersister getSubclassEntityPersister(Object instance, SessionFactoryImplementor factory, EntityMode entityMode) {
+ return this;
+ }
+}
\ No newline at end of file
Copied: trunk/src/main-3.3/org/jboss/envers/entity/VersionsInheritanceEntityPersisterFor33.java (from rev 87, trunk/src/main-3.3/org/jboss/envers/entity/VersionsInheritanceEntityPersisterFor330.java)
===================================================================
--- trunk/src/main-3.3/org/jboss/envers/entity/VersionsInheritanceEntityPersisterFor33.java (rev 0)
+++ trunk/src/main-3.3/org/jboss/envers/entity/VersionsInheritanceEntityPersisterFor33.java 2008-07-03 11:35:48 UTC (rev 88)
@@ -0,0 +1,45 @@
+/*
+ * Envers. http://www.jboss.org/envers
+ *
+ * Copyright 2008 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * 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, v. 2.1.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT A 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, v.2.1 along with this distribution; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ * Red Hat Author(s): Adam Warski
+ */
+package org.jboss.envers.entity;
+
+import org.hibernate.persister.entity.SingleTableEntityPersister;
+import org.hibernate.persister.entity.EntityPersister;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.cache.access.EntityRegionAccessStrategy;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.engine.Mapping;
+import org.hibernate.HibernateException;
+import org.hibernate.EntityMode;
+
+/**
+ * @author Adam Warski (adam at warski dot org)
+ */
+public class VersionsInheritanceEntityPersisterFor33 extends SingleTableEntityPersister {
+ public VersionsInheritanceEntityPersisterFor33(PersistentClass persistentClass, EntityRegionAccessStrategy entityRegionAccessStrategy, SessionFactoryImplementor factory, Mapping mapping) throws HibernateException {
+ super(persistentClass, entityRegionAccessStrategy, factory, mapping);
+ }
+
+ // A hack for http://opensource.atlassian.com/projects/hibernate/browse/HHH-3351
+ public EntityPersister getSubclassEntityPersister(Object instance, SessionFactoryImplementor factory, EntityMode entityMode) {
+ return this;
+ }
+}
\ No newline at end of file
Deleted: trunk/src/main-3.3/org/jboss/envers/entity/VersionsInheritanceEntityPersisterFor330.java
===================================================================
--- trunk/src/main-3.3/org/jboss/envers/entity/VersionsInheritanceEntityPersisterFor330.java 2008-06-24 14:06:27 UTC (rev 87)
+++ trunk/src/main-3.3/org/jboss/envers/entity/VersionsInheritanceEntityPersisterFor330.java 2008-07-03 11:35:48 UTC (rev 88)
@@ -1,45 +0,0 @@
-/*
- * Envers. http://www.jboss.org/envers
- *
- * Copyright 2008 Red Hat Middleware, LLC. All rights reserved.
- *
- * 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, v. 2.1.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT A 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, v.2.1 along with this distribution; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- *
- * Red Hat Author(s): Adam Warski
- */
-package org.jboss.envers.entity;
-
-import org.hibernate.persister.entity.SingleTableEntityPersister;
-import org.hibernate.persister.entity.EntityPersister;
-import org.hibernate.mapping.PersistentClass;
-import org.hibernate.cache.access.EntityRegionAccessStrategy;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.engine.Mapping;
-import org.hibernate.HibernateException;
-import org.hibernate.EntityMode;
-
-/**
- * @author Adam Warski (adam at warski dot org)
- */
-public class VersionsInheritanceEntityPersisterFor330 extends SingleTableEntityPersister {
- public VersionsInheritanceEntityPersisterFor330(PersistentClass persistentClass, EntityRegionAccessStrategy entityRegionAccessStrategy, SessionFactoryImplementor factory, Mapping mapping) throws HibernateException {
- super(persistentClass, entityRegionAccessStrategy, factory, mapping);
- }
-
- // A hack for http://opensource.atlassian.com/projects/hibernate/browse/HHH-3351
- public EntityPersister getSubclassEntityPersister(Object instance, SessionFactoryImplementor factory, EntityMode entityMode) {
- return this;
- }
-}
\ No newline at end of file
Modified: trunk/src/test/org/jboss/envers/test/working/WorkingEntity1.java
===================================================================
--- trunk/src/test/org/jboss/envers/test/working/WorkingEntity1.java 2008-06-24 14:06:27 UTC (rev 87)
+++ trunk/src/test/org/jboss/envers/test/working/WorkingEntity1.java 2008-07-03 11:35:48 UTC (rev 88)
@@ -25,10 +25,10 @@
//@Column(table = "second_table", name = "cc_second")
private String cc;
- @Versioned
+ //@Versioned
//@OneToOne
- @ManyToOne
- //@Transient
+ //@ManyToOne
+ @Transient
private WorkingEntity2 we2;
public WorkingEntity1() {
Modified: trunk/src/test/org/jboss/envers/test/working/WorkingEntity2.java
===================================================================
--- trunk/src/test/org/jboss/envers/test/working/WorkingEntity2.java 2008-06-24 14:06:27 UTC (rev 87)
+++ trunk/src/test/org/jboss/envers/test/working/WorkingEntity2.java 2008-07-03 11:35:48 UTC (rev 88)
@@ -22,7 +22,8 @@
@Versioned
//@OneToMany(mappedBy = "we2")
- @Transient
+ @ManyToMany
+ //@Transient
private Set<WorkingEntity1> we1s;
//@Versioned
Modified: trunk/src/test/org/jboss/envers/test/working/WorkingMain.java
===================================================================
--- trunk/src/test/org/jboss/envers/test/working/WorkingMain.java 2008-06-24 14:06:27 UTC (rev 87)
+++ trunk/src/test/org/jboss/envers/test/working/WorkingMain.java 2008-07-03 11:35:48 UTC (rev 88)
@@ -50,7 +50,7 @@
cfg.configure("hibernate.test.cfg.xml");
cfg.addAnnotatedClass(WorkingEntity1.class);
cfg.addAnnotatedClass(WorkingEntity2.class);
- cfg.addAnnotatedClass(RevEntity.class);
+ //cfg.addAnnotatedClass(RevEntity.class);
//cfg.addAnnotatedClass(PostalAddress.class);
//cfg.addAnnotatedClass(ContactMech.class);
Modified: trunk/src/test/org/jboss/envers/test/working/test.hbm.xml
===================================================================
--- trunk/src/test/org/jboss/envers/test/working/test.hbm.xml 2008-06-24 14:06:27 UTC (rev 87)
+++ trunk/src/test/org/jboss/envers/test/working/test.hbm.xml 2008-07-03 11:35:48 UTC (rev 88)
@@ -3,7 +3,7 @@
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
- <class entity-name="Superclass" discriminator-value="A" persister="org.jboss.envers.entity.VersionsInheritanceEntityPersister">
+ <class entity-name="Superclass" discriminator-value="A" persister="org.jboss.envers.entity.VersionsInheritanceEntityPersisterFor32">
<id name="id" type="integer"><generator class="native"/></id>
<discriminator column="DISC" type="string" />
16 years, 4 months