From 95ec3457af961c4116015509180dcca04967604f Mon Sep 17 00:00:00 2001 From: Lukasz Antoniak Date: Thu, 19 Apr 2012 23:49:41 +0200 Subject: [PATCH] HHH-7187 - Renaming and documenting enhanced revision entity --- .../main/docbook/devguide/en-US/Envers.xml | 19 ++++++++++++++++ .../configuration/GlobalConfiguration.java | 18 +++++++-------- .../RevisionInfoConfiguration.java | 22 ++++++++++--------- .../configuration/metadata/MetadataTools.java | 8 +++---- ...ity.java => SequenceIdRevisionEntity.java} | 8 +++---- ...ackingModifiedEntitiesRevisionEntity.java} | 10 ++++----- .../envers/test/AbstractOneSessionTest.java | 2 +- .../test/BaseEnversFunctionalTestCase.java | 2 +- .../test/BaseEnversJPAFunctionalTestCase.java | 2 +- .../ExtendedRevisionEntity.java | 4 ++-- .../test/integration/jta/JtaTransaction.java | 7 +++--- .../integration/query/DeletedEntities.java | 4 ++-- .../test/integration/query/SimpleQuery.java | 8 +++---- .../reventity/DifferentDBSchemaTest.java | 2 +- .../reventity/InheritedRevEntity.java | 4 ++-- .../ValidityAuditStrategyRevEndTsTest.java | 10 ++++----- .../AbstractEntityManagerTest.java | 2 +- .../EvictAuditDataAfterCommitTest.java | 6 ++--- .../envers/test/tools/TestTools.java | 4 ++-- 19 files changed, 81 insertions(+), 61 deletions(-) rename hibernate-envers/src/main/java/org/hibernate/envers/enhanced/{DefaultRevisionEntity.java => SequenceIdRevisionEntity.java} (90%) rename hibernate-envers/src/main/java/org/hibernate/envers/enhanced/{DefaultTrackingModifiedEntitiesRevisionEntity.java => SequenceIdTrackingModifiedEntitiesRevisionEntity.java} (82%) diff --git a/documentation/src/main/docbook/devguide/en-US/Envers.xml b/documentation/src/main/docbook/devguide/en-US/Envers.xml index 51c1650fbc..2f04dc4469 100644 --- a/documentation/src/main/docbook/devguide/en-US/Envers.xml +++ b/documentation/src/main/docbook/devguide/en-US/Envers.xml @@ -251,6 +251,25 @@ evaluates to true + + + org.hibernate.envers.use_revision_entity_with_native_id + + + true + + + Boolean flag that determines the strategy of revision number generation. Default + implementation of revision entity uses native identifier generator. If current database + engine does not support identity columns, users are advised to set this property to false. + In this case revision numbers are created by preconfigured + org.hibernate.id.enhanced.SequenceStyleGenerator. See: + + org.hibernate.envers.DefaultRevisionEntity + org.hibernate.envers.enhanced.SequenceIdRevisionEntity + + + org.hibernate.envers.track_entities_changed_in_revision diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/GlobalConfiguration.java b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/GlobalConfiguration.java index 06daf176d6..a7d0fd7bee 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/GlobalConfiguration.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/GlobalConfiguration.java @@ -70,8 +70,8 @@ public class GlobalConfiguration { // Suffix to be used for modified flags columns private String modifiedFlagSuffix; - // Use enhanced default revision entity (only for internal use) - private final boolean useEnhancedRevisionEntity; + // Use revision entity with native id generator + private final boolean useRevisionEntityWithNativeId; /* Which operator to use in correlated subqueries (when we want a property to be equal to the result of @@ -112,11 +112,11 @@ public class GlobalConfiguration { "false"); trackEntitiesChangedInRevisionEnabled = Boolean.parseBoolean(trackEntitiesChangedInRevisionEnabledStr); - String useEnhancedRevisionEntityStr = getProperty(properties, - "org.hibernate.envers.use_enhanced_revision_entity", - "org.hibernate.envers.use_enhanced_revision_entity", - "false"); - useEnhancedRevisionEntity = Boolean.parseBoolean(useEnhancedRevisionEntityStr); + String useRevisionEntityWithNativeIdStr = getProperty(properties, + "org.hibernate.envers.use_revision_entity_with_native_id", + "org.hibernate.envers.use_revision_entity_with_native_id", + "true"); + useRevisionEntityWithNativeId = Boolean.parseBoolean(useRevisionEntityWithNativeIdStr); hasGlobalSettingForWithModifiedFlag = properties.getProperty(GLOBAL_WITH_MODIFIED_FLAG_PROPERTY) != null; @@ -191,7 +191,7 @@ public class GlobalConfiguration { return modifiedFlagSuffix; } - public boolean isUseEnhancedRevisionEntity() { - return useEnhancedRevisionEntity; + public boolean isUseRevisionEntityWithNativeId() { + return useRevisionEntityWithNativeId; } } diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/RevisionInfoConfiguration.java b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/RevisionInfoConfiguration.java index 69547c7bde..43a98ed50d 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/RevisionInfoConfiguration.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/RevisionInfoConfiguration.java @@ -45,6 +45,8 @@ import org.hibernate.envers.RevisionNumber; import org.hibernate.envers.RevisionTimestamp; import org.hibernate.envers.configuration.metadata.AuditTableData; import org.hibernate.envers.configuration.metadata.MetadataTools; +import org.hibernate.envers.enhanced.SequenceIdRevisionEntity; +import org.hibernate.envers.enhanced.SequenceIdTrackingModifiedEntitiesRevisionEntity; import org.hibernate.envers.entities.PropertyData; import org.hibernate.envers.revisioninfo.DefaultRevisionInfoGenerator; import org.hibernate.envers.revisioninfo.DefaultTrackingModifiedEntitiesRevisionInfoGenerator; @@ -75,10 +77,10 @@ public class RevisionInfoConfiguration { public RevisionInfoConfiguration(GlobalConfiguration globalCfg) { this.globalCfg = globalCfg; - if (globalCfg.isUseEnhancedRevisionEntity()) { - revisionInfoEntityName = "org.hibernate.envers.enhanced.DefaultRevisionEntity"; - } else { + if (globalCfg.isUseRevisionEntityWithNativeId()) { revisionInfoEntityName = "org.hibernate.envers.DefaultRevisionEntity"; + } else { + revisionInfoEntityName = "org.hibernate.envers.enhanced.SequenceIdRevisionEntity"; } revisionInfoIdData = new PropertyData("id", "id", "field", null); revisionInfoTimestampData = new PropertyData("timestamp", "timestamp", "field", null); @@ -97,7 +99,7 @@ public class RevisionInfoConfiguration { class_mapping.addAttribute("table", "REVINFO"); Element idProperty = MetadataTools.addNativelyGeneratedId(class_mapping, revisionInfoIdData.getName(), - revisionPropType, globalCfg.isUseEnhancedRevisionEntity()); + revisionPropType, globalCfg.isUseRevisionEntityWithNativeId()); MetadataTools.addColumn(idProperty, "REV", null, null, null, null, null, null, false); Element timestampProperty = MetadataTools.addProperty(class_mapping, revisionInfoTimestampData.getName(), @@ -296,8 +298,8 @@ public class RevisionInfoConfiguration { Class revisionListenerClass = getRevisionListenerClass(revisionEntity.value()); revisionInfoTimestampType = pc.getProperty(revisionInfoTimestampData.getName()).getType(); if (globalCfg.isTrackEntitiesChangedInRevisionEnabled() - || (!globalCfg.isUseEnhancedRevisionEntity() && DefaultTrackingModifiedEntitiesRevisionEntity.class.isAssignableFrom(revisionInfoClass)) - || (globalCfg.isUseEnhancedRevisionEntity() && org.hibernate.envers.enhanced.DefaultTrackingModifiedEntitiesRevisionEntity.class.isAssignableFrom(revisionInfoClass)) + || (globalCfg.isUseRevisionEntityWithNativeId() && DefaultTrackingModifiedEntitiesRevisionEntity.class.isAssignableFrom(revisionInfoClass)) + || (!globalCfg.isUseRevisionEntityWithNativeId() && SequenceIdTrackingModifiedEntitiesRevisionEntity.class.isAssignableFrom(revisionInfoClass)) || modifiedEntityNamesFound.isSet()) { // If tracking modified entities parameter is enabled, custom revision info entity is a subtype // of DefaultTrackingModifiedEntitiesRevisionEntity class, or @ModifiedEntityNames annotation is used. @@ -319,14 +321,14 @@ public class RevisionInfoConfiguration { if (revisionInfoGenerator == null) { if (globalCfg.isTrackEntitiesChangedInRevisionEnabled()) { - revisionInfoClass = globalCfg.isUseEnhancedRevisionEntity() ? org.hibernate.envers.enhanced.DefaultTrackingModifiedEntitiesRevisionEntity.class - : DefaultTrackingModifiedEntitiesRevisionEntity.class; + revisionInfoClass = globalCfg.isUseRevisionEntityWithNativeId() ? DefaultTrackingModifiedEntitiesRevisionEntity.class + : SequenceIdTrackingModifiedEntitiesRevisionEntity.class; revisionInfoEntityName = revisionInfoClass.getName(); revisionInfoGenerator = new DefaultTrackingModifiedEntitiesRevisionInfoGenerator(revisionInfoEntityName, revisionInfoClass, revisionListenerClass, revisionInfoTimestampData, isTimestampAsDate(), modifiedEntityNamesData); } else { - revisionInfoClass = globalCfg.isUseEnhancedRevisionEntity() ? org.hibernate.envers.enhanced.DefaultRevisionEntity.class - : DefaultRevisionEntity.class; + revisionInfoClass = globalCfg.isUseRevisionEntityWithNativeId() ? DefaultRevisionEntity.class + : SequenceIdRevisionEntity.class; revisionInfoGenerator = new DefaultRevisionInfoGenerator(revisionInfoEntityName, revisionInfoClass, revisionListenerClass, revisionInfoTimestampData, isTimestampAsDate()); } diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/metadata/MetadataTools.java b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/metadata/MetadataTools.java index bd0820c4ed..76ba6c0b76 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/metadata/MetadataTools.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/metadata/MetadataTools.java @@ -41,19 +41,19 @@ import org.hibernate.mapping.Formula; public class MetadataTools { public static Element addNativelyGeneratedId(Element parent, String name, String type, - boolean useEnhancedRevisionEntity) { + boolean useRevisionEntityWithNativeId) { Element id_mapping = parent.addElement("id"); id_mapping.addAttribute("name", name).addAttribute("type", type); Element generator_mapping = id_mapping.addElement("generator"); - if (useEnhancedRevisionEntity) { + if (useRevisionEntityWithNativeId) { + generator_mapping.addAttribute("class", "native"); + } else { generator_mapping.addAttribute("class", "org.hibernate.id.enhanced.SequenceStyleGenerator"); generator_mapping.addElement("param").addAttribute("name", "sequence_name").setText("REVISION_GENERATOR"); generator_mapping.addElement("param").addAttribute("name", "table_name").setText("REVISION_GENERATOR"); generator_mapping.addElement("param").addAttribute("name", "initial_value").setText("1"); generator_mapping.addElement("param").addAttribute("name", "increment_size").setText("1"); - } else { - generator_mapping.addAttribute("class", "native"); } // generator_mapping.addAttribute("class", "sequence"); // generator_mapping.addElement("param").addAttribute("name", "sequence").setText("custom"); diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/enhanced/DefaultRevisionEntity.java b/hibernate-envers/src/main/java/org/hibernate/envers/enhanced/SequenceIdRevisionEntity.java similarity index 90% rename from hibernate-envers/src/main/java/org/hibernate/envers/enhanced/DefaultRevisionEntity.java rename to hibernate-envers/src/main/java/org/hibernate/envers/enhanced/SequenceIdRevisionEntity.java index ef86d1e3f5..6115723006 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/enhanced/DefaultRevisionEntity.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/enhanced/SequenceIdRevisionEntity.java @@ -41,7 +41,7 @@ import java.util.Date; * @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com) */ @MappedSuperclass -public class DefaultRevisionEntity implements Serializable { +public class SequenceIdRevisionEntity implements Serializable { private static final long serialVersionUID = 4159156677698841902L; @Id @@ -83,9 +83,9 @@ public class DefaultRevisionEntity implements Serializable { public boolean equals(Object o) { if (this == o) return true; - if (!(o instanceof DefaultRevisionEntity)) return false; + if (!(o instanceof SequenceIdRevisionEntity )) return false; - DefaultRevisionEntity that = (DefaultRevisionEntity) o; + SequenceIdRevisionEntity that = (SequenceIdRevisionEntity) o; if (id != that.id) return false; if (timestamp != that.timestamp) return false; @@ -100,6 +100,6 @@ public class DefaultRevisionEntity implements Serializable { } public String toString() { - return "DefaultRevisionEntity(id = " + id + ", revisionDate = " + DateFormat.getDateTimeInstance().format(getRevisionDate()) + ")"; + return "SequenceIdRevisionEntity(id = " + id + ", revisionDate = " + DateFormat.getDateTimeInstance().format(getRevisionDate()) + ")"; } } diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/enhanced/DefaultTrackingModifiedEntitiesRevisionEntity.java b/hibernate-envers/src/main/java/org/hibernate/envers/enhanced/SequenceIdTrackingModifiedEntitiesRevisionEntity.java similarity index 82% rename from hibernate-envers/src/main/java/org/hibernate/envers/enhanced/DefaultTrackingModifiedEntitiesRevisionEntity.java rename to hibernate-envers/src/main/java/org/hibernate/envers/enhanced/SequenceIdTrackingModifiedEntitiesRevisionEntity.java index 78ac8ff066..fd02295ea4 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/enhanced/DefaultTrackingModifiedEntitiesRevisionEntity.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/enhanced/SequenceIdTrackingModifiedEntitiesRevisionEntity.java @@ -32,13 +32,13 @@ import java.util.HashSet; import java.util.Set; /** - * Extension of standard {@link DefaultRevisionEntity} that allows tracking entity names changed in each revision. + * Extension of standard {@link SequenceIdRevisionEntity} that allows tracking entity names changed in each revision. * This revision entity is implicitly used when {@code org.hibernate.envers.track_entities_changed_in_revision} * parameter is set to {@code true}. * @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com) */ @MappedSuperclass -public class DefaultTrackingModifiedEntitiesRevisionEntity extends DefaultRevisionEntity { +public class SequenceIdTrackingModifiedEntitiesRevisionEntity extends SequenceIdRevisionEntity { @ElementCollection(fetch = FetchType.EAGER) @JoinTable(name = "REVCHANGES", joinColumns = @JoinColumn(name = "REV")) @Column(name = "ENTITYNAME") @@ -56,10 +56,10 @@ public class DefaultTrackingModifiedEntitiesRevisionEntity extends DefaultRevisi public boolean equals(Object o) { if (this == o) return true; - if (!(o instanceof DefaultTrackingModifiedEntitiesRevisionEntity)) return false; + if (!(o instanceof SequenceIdTrackingModifiedEntitiesRevisionEntity )) return false; if (!super.equals(o)) return false; - DefaultTrackingModifiedEntitiesRevisionEntity that = (DefaultTrackingModifiedEntitiesRevisionEntity) o; + SequenceIdTrackingModifiedEntitiesRevisionEntity that = (SequenceIdTrackingModifiedEntitiesRevisionEntity) o; if (modifiedEntityNames != null ? !modifiedEntityNames.equals(that.modifiedEntityNames) : that.modifiedEntityNames != null) return false; @@ -74,6 +74,6 @@ public class DefaultTrackingModifiedEntitiesRevisionEntity extends DefaultRevisi } public String toString() { - return "DefaultTrackingModifiedEntitiesRevisionEntity(" + super.toString() + ", modifiedEntityNames = " + modifiedEntityNames + ")"; + return "SequenceIdTrackingModifiedEntitiesRevisionEntity(" + super.toString() + ", modifiedEntityNames = " + modifiedEntityNames + ")"; } } diff --git a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/AbstractOneSessionTest.java b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/AbstractOneSessionTest.java index 7f277ade0b..f14de44b5b 100644 --- a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/AbstractOneSessionTest.java +++ b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/AbstractOneSessionTest.java @@ -43,7 +43,7 @@ public abstract class AbstractOneSessionTest extends AbstractEnversTest { config.setProperty("org.hibernate.envers.audit_strategy", auditStrategy); } config.setProperty( Environment.USE_NEW_ID_GENERATOR_MAPPINGS, "true" ); - config.setProperty("org.hibernate.envers.use_enhanced_revision_entity", "true"); + config.setProperty("org.hibernate.envers.use_revision_entity_with_native_id", "false"); addProperties(config); this.initMappings(); diff --git a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/BaseEnversFunctionalTestCase.java b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/BaseEnversFunctionalTestCase.java index 0d2bdc44af..963a57db23 100644 --- a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/BaseEnversFunctionalTestCase.java +++ b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/BaseEnversFunctionalTestCase.java @@ -49,7 +49,7 @@ public abstract class BaseEnversFunctionalTestCase extends BaseCoreFunctionalTes @Override protected Configuration constructConfiguration() { Configuration configuration = super.constructConfiguration(); - configuration.setProperty("org.hibernate.envers.use_enhanced_revision_entity", "true"); + configuration.setProperty("org.hibernate.envers.use_revision_entity_with_native_id", "false"); return configuration; } diff --git a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/BaseEnversJPAFunctionalTestCase.java b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/BaseEnversJPAFunctionalTestCase.java index 675a34a4d3..9ffeede602 100644 --- a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/BaseEnversJPAFunctionalTestCase.java +++ b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/BaseEnversJPAFunctionalTestCase.java @@ -114,7 +114,7 @@ public abstract class BaseEnversJPAFunctionalTestCase extends AbstractEnversTest ejb3Configuration .getHibernateConfiguration() - .setProperty( "org.hibernate.envers.use_enhanced_revision_entity", "true" ); + .setProperty( "org.hibernate.envers.use_revision_entity_with_native_id", "false" ); ejb3Configuration .getHibernateConfiguration() diff --git a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/entities/reventity/trackmodifiedentities/ExtendedRevisionEntity.java b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/entities/reventity/trackmodifiedentities/ExtendedRevisionEntity.java index 9e25f745ac..17330e46ea 100644 --- a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/entities/reventity/trackmodifiedentities/ExtendedRevisionEntity.java +++ b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/entities/reventity/trackmodifiedentities/ExtendedRevisionEntity.java @@ -3,7 +3,7 @@ package org.hibernate.envers.test.entities.reventity.trackmodifiedentities; import javax.persistence.Column; import javax.persistence.Entity; -import org.hibernate.envers.enhanced.DefaultTrackingModifiedEntitiesRevisionEntity; +import org.hibernate.envers.enhanced.SequenceIdTrackingModifiedEntitiesRevisionEntity; import org.hibernate.envers.RevisionEntity; /** @@ -11,7 +11,7 @@ import org.hibernate.envers.RevisionEntity; */ @Entity @RevisionEntity(ExtendedRevisionListener.class) -public class ExtendedRevisionEntity extends DefaultTrackingModifiedEntitiesRevisionEntity { +public class ExtendedRevisionEntity extends SequenceIdTrackingModifiedEntitiesRevisionEntity { @Column(name = "USER_COMMENT") private String comment; diff --git a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/jta/JtaTransaction.java b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/jta/JtaTransaction.java index 11710e5712..d71bc2816a 100644 --- a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/jta/JtaTransaction.java +++ b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/jta/JtaTransaction.java @@ -8,6 +8,7 @@ import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase; import org.hibernate.envers.test.Priority; import org.hibernate.envers.test.entities.IntTestEntity; +import org.junit.Assert; import org.junit.Test; import org.hibernate.testing.jta.TestingJtaBootstrap; @@ -60,7 +61,7 @@ public class JtaTransaction extends BaseEnversJPAFunctionalTestCase { @Test public void testRevisionsCounts() throws Exception { - assert Arrays.asList(1, 2).equals(getAuditReader().getRevisions(IntTestEntity.class, id1)); + Assert.assertEquals(Arrays.asList(1, 2), getAuditReader().getRevisions(IntTestEntity.class, id1)); } @Test @@ -68,7 +69,7 @@ public class JtaTransaction extends BaseEnversJPAFunctionalTestCase { IntTestEntity ver1 = new IntTestEntity(10, id1); IntTestEntity ver2 = new IntTestEntity(20, id1); - assert getAuditReader().find(IntTestEntity.class, id1, 1).equals(ver1); - assert getAuditReader().find(IntTestEntity.class, id1, 2).equals(ver2); + Assert.assertEquals(ver1, getAuditReader().find(IntTestEntity.class, id1, 1)); + Assert.assertEquals(ver2, getAuditReader().find(IntTestEntity.class, id1, 2)); } } diff --git a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/query/DeletedEntities.java b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/query/DeletedEntities.java index df20742429..923c2d2e38 100644 --- a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/query/DeletedEntities.java +++ b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/query/DeletedEntities.java @@ -29,7 +29,7 @@ import javax.persistence.EntityManager; import org.junit.Test; import org.hibernate.ejb.Ejb3Configuration; -import org.hibernate.envers.enhanced.DefaultRevisionEntity; +import org.hibernate.envers.enhanced.SequenceIdRevisionEntity; import org.hibernate.envers.RevisionType; import org.hibernate.envers.query.AuditEntity; import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase; @@ -95,7 +95,7 @@ public class DeletedEntities extends BaseEnversJPAFunctionalTestCase { assert result.size() == 1; assert ((Object []) result.get(0))[0].equals(new StrIntTestEntity("b", 11, id2)); - assert ((DefaultRevisionEntity) ((Object []) result.get(0))[1]).getId() == 1; + assert ((SequenceIdRevisionEntity) ((Object []) result.get(0))[1]).getId() == 1; assert ((Object []) result.get(0))[2].equals(RevisionType.ADD); } } diff --git a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/query/SimpleQuery.java b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/query/SimpleQuery.java index d9cd57c960..b07c627b83 100644 --- a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/query/SimpleQuery.java +++ b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/query/SimpleQuery.java @@ -32,7 +32,7 @@ import org.junit.Assert; import org.junit.Test; import org.hibernate.ejb.Ejb3Configuration; -import org.hibernate.envers.enhanced.DefaultRevisionEntity; +import org.hibernate.envers.enhanced.SequenceIdRevisionEntity; import org.hibernate.envers.RevisionType; import org.hibernate.envers.query.AuditEntity; import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase; @@ -218,9 +218,9 @@ public class SimpleQuery extends BaseEnversJPAFunctionalTestCase { assert ((Object []) result.get(1))[0].equals(new StrIntTestEntity("c", 10, id1)); assert ((Object []) result.get(2))[0].equals(new StrIntTestEntity(null, null, id1)); - assert ((DefaultRevisionEntity) ((Object []) result.get(0))[1]).getId() == 1; - assert ((DefaultRevisionEntity) ((Object []) result.get(1))[1]).getId() == 2; - assert ((DefaultRevisionEntity) ((Object []) result.get(2))[1]).getId() == 4; + assert ((SequenceIdRevisionEntity) ((Object []) result.get(0))[1]).getId() == 1; + assert ((SequenceIdRevisionEntity) ((Object []) result.get(1))[1]).getId() == 2; + assert ((SequenceIdRevisionEntity) ((Object []) result.get(2))[1]).getId() == 4; assert ((Object []) result.get(0))[2].equals(RevisionType.ADD); assert ((Object []) result.get(1))[2].equals(RevisionType.MOD); diff --git a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/reventity/DifferentDBSchemaTest.java b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/reventity/DifferentDBSchemaTest.java index 8fdbcb7161..11aa42ea3f 100644 --- a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/reventity/DifferentDBSchemaTest.java +++ b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/reventity/DifferentDBSchemaTest.java @@ -59,7 +59,7 @@ public class DifferentDBSchemaTest extends BaseEnversJPAFunctionalTestCase { @Test public void testRevinfoSchemaName() { - Table revisionTable = getCfg().getClassMapping("org.hibernate.envers.enhanced.DefaultRevisionEntity").getTable(); + Table revisionTable = getCfg().getClassMapping("org.hibernate.envers.enhanced.SequenceIdRevisionEntity").getTable(); assert SCHEMA_NAME.equals(revisionTable.getSchema()); } diff --git a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/reventity/InheritedRevEntity.java b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/reventity/InheritedRevEntity.java index 6424ea2997..285b705dea 100644 --- a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/reventity/InheritedRevEntity.java +++ b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/reventity/InheritedRevEntity.java @@ -24,7 +24,7 @@ package org.hibernate.envers.test.integration.reventity; import javax.persistence.Entity; -import org.hibernate.envers.enhanced.DefaultRevisionEntity; +import org.hibernate.envers.enhanced.SequenceIdRevisionEntity; import org.hibernate.envers.RevisionEntity; /** @@ -32,5 +32,5 @@ import org.hibernate.envers.RevisionEntity; */ @Entity @RevisionEntity -public class InheritedRevEntity extends DefaultRevisionEntity { +public class InheritedRevEntity extends SequenceIdRevisionEntity { } diff --git a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/strategy/ValidityAuditStrategyRevEndTsTest.java b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/strategy/ValidityAuditStrategyRevEndTsTest.java index bfab016e56..994d9d5806 100644 --- a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/strategy/ValidityAuditStrategyRevEndTsTest.java +++ b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/integration/strategy/ValidityAuditStrategyRevEndTsTest.java @@ -28,7 +28,6 @@ import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Properties; import java.util.Set; import javax.persistence.EntityManager; import javax.persistence.Query; @@ -42,7 +41,7 @@ import org.hibernate.dialect.MySQL5Dialect; import org.hibernate.dialect.PostgreSQL82Dialect; import org.hibernate.dialect.SQLServerDialect; import org.hibernate.ejb.Ejb3Configuration; -import org.hibernate.envers.enhanced.DefaultRevisionEntity; +import org.hibernate.envers.enhanced.SequenceIdRevisionEntity; import org.hibernate.envers.strategy.ValidityAuditStrategy; import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase; import org.hibernate.envers.test.Priority; @@ -66,7 +65,7 @@ public class ValidityAuditStrategyRevEndTsTest extends BaseEnversJPAFunctionalTe private Integer c1_2_id; private Integer c2_1_id; private Integer c2_2_id; - private Map revisions; + private Map revisions; public void configure(Ejb3Configuration cfg) { cfg.addAnnotatedClass(ParentEntity.class); @@ -204,7 +203,8 @@ public class ValidityAuditStrategyRevEndTsTest extends BaseEnversJPAFunctionalTe Set revisionNumbers = new HashSet(); revisionNumbers.addAll(Arrays.asList(1, 2, 3, 4, 5)); - revisions = getAuditReader().findRevisions(DefaultRevisionEntity.class, + revisions = getAuditReader().findRevisions( + SequenceIdRevisionEntity.class, revisionNumbers); assert revisions.size() == 5; @@ -423,7 +423,7 @@ public class ValidityAuditStrategyRevEndTsTest extends BaseEnversJPAFunctionalTe private void verifyRevEndTimeStamps(String debugInfo, List> revisionEntities) { for (Map revisionEntity : revisionEntities) { Date revendTimestamp = (Date) revisionEntity.get(revendTimestampColumName); - DefaultRevisionEntity revEnd = (DefaultRevisionEntity) revisionEntity.get("REVEND"); + SequenceIdRevisionEntity revEnd = (SequenceIdRevisionEntity) revisionEntity.get("REVEND"); if (revendTimestamp == null) { Assert.assertNull(revEnd); diff --git a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/performance/AbstractEntityManagerTest.java b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/performance/AbstractEntityManagerTest.java index fb315dfba1..17f1b60090 100644 --- a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/performance/AbstractEntityManagerTest.java +++ b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/performance/AbstractEntityManagerTest.java @@ -99,7 +99,7 @@ public abstract class AbstractEntityManagerTest extends AbstractEnversTest { if ( createSchema() ) { configurationProperties.setProperty( Environment.HBM2DDL_AUTO, "create-drop" ); configurationProperties.setProperty( Environment.USE_NEW_ID_GENERATOR_MAPPINGS, "true" ); - configurationProperties.setProperty("org.hibernate.envers.use_enhanced_revision_entity", "true"); + configurationProperties.setProperty("org.hibernate.envers.use_revision_entity_with_native_id", "false"); } if (auditStrategy != null && !"".equals(auditStrategy)) { configurationProperties.setProperty("org.hibernate.envers.audit_strategy", auditStrategy); diff --git a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/performance/EvictAuditDataAfterCommitTest.java b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/performance/EvictAuditDataAfterCommitTest.java index dee32bdf67..9999914314 100644 --- a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/performance/EvictAuditDataAfterCommitTest.java +++ b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/performance/EvictAuditDataAfterCommitTest.java @@ -1,6 +1,5 @@ package org.hibernate.envers.test.performance; -import java.net.URISyntaxException; import java.util.Arrays; import java.util.HashSet; import java.util.List; @@ -9,12 +8,11 @@ import java.util.Set; import org.junit.Assert; import org.junit.Test; -import org.hibernate.MappingException; import org.hibernate.Session; import org.hibernate.engine.spi.EntityEntry; import org.hibernate.engine.spi.PersistenceContext; import org.hibernate.engine.spi.SessionImplementor; -import org.hibernate.envers.enhanced.DefaultRevisionEntity; +import org.hibernate.envers.enhanced.SequenceIdRevisionEntity; import org.hibernate.envers.test.BaseEnversFunctionalTestCase; import org.hibernate.envers.test.entities.StrTestEntity; import org.hibernate.envers.test.entities.onetomany.SetRefEdEntity; @@ -101,7 +99,7 @@ public class EvictAuditDataAfterCommitTest extends BaseEnversFunctionalTestCase assert false : "Audit data shall not be stored in the session level cache. This causes performance issues."; } Assert.assertFalse("Revision entity shall not be stored in the session level cache. This causes performance issues.", - DefaultRevisionEntity.class.getName().equals(entityEntry.getEntityName())); + SequenceIdRevisionEntity.class.getName().equals(entityEntry.getEntityName())); } } } \ No newline at end of file diff --git a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/tools/TestTools.java b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/tools/TestTools.java index f4490c04ae..ae3dfcd492 100644 --- a/hibernate-envers/src/matrix/java/org/hibernate/envers/test/tools/TestTools.java +++ b/hibernate-envers/src/matrix/java/org/hibernate/envers/test/tools/TestTools.java @@ -32,7 +32,7 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.hibernate.envers.enhanced.DefaultRevisionEntity; +import org.hibernate.envers.enhanced.SequenceIdRevisionEntity; import org.hibernate.envers.configuration.GlobalConfiguration; import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.Property; @@ -83,7 +83,7 @@ public class TestTools { public static List extractRevisionNumbers(List queryResults) { List result = new ArrayList(); for (Object queryResult : queryResults) { - result.add(((DefaultRevisionEntity) ((Object[]) queryResult)[1]) + result.add(((SequenceIdRevisionEntity) ((Object[]) queryResult)[1]) .getId()); } return result;