HHH-7187 - Renaming and documenting enhanced revision entity

This commit is contained in:
Lukasz Antoniak 2012-04-19 23:49:41 +02:00
parent c41fee2a07
commit 95ec3457af
19 changed files with 81 additions and 61 deletions

View File

@ -251,6 +251,25 @@
evaluates to true evaluates to true
</entry> </entry>
</row> </row>
<row>
<entry>
<property>org.hibernate.envers.use_revision_entity_with_native_id</property>
</entry>
<entry>
true
</entry>
<entry>
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
<classname>org.hibernate.id.enhanced.SequenceStyleGenerator</classname>. See:
<orderedlist>
<listitem><classname>org.hibernate.envers.DefaultRevisionEntity</classname></listitem>
<listitem><classname>org.hibernate.envers.enhanced.SequenceIdRevisionEntity</classname></listitem>
</orderedlist>
</entry>
</row>
<row> <row>
<entry> <entry>
<property>org.hibernate.envers.track_entities_changed_in_revision</property> <property>org.hibernate.envers.track_entities_changed_in_revision</property>

View File

@ -70,8 +70,8 @@ public class GlobalConfiguration {
// Suffix to be used for modified flags columns // Suffix to be used for modified flags columns
private String modifiedFlagSuffix; private String modifiedFlagSuffix;
// Use enhanced default revision entity (only for internal use) // Use revision entity with native id generator
private final boolean useEnhancedRevisionEntity; private final boolean useRevisionEntityWithNativeId;
/* /*
Which operator to use in correlated subqueries (when we want a property to be equal to the result of 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"); "false");
trackEntitiesChangedInRevisionEnabled = Boolean.parseBoolean(trackEntitiesChangedInRevisionEnabledStr); trackEntitiesChangedInRevisionEnabled = Boolean.parseBoolean(trackEntitiesChangedInRevisionEnabledStr);
String useEnhancedRevisionEntityStr = getProperty(properties, String useRevisionEntityWithNativeIdStr = getProperty(properties,
"org.hibernate.envers.use_enhanced_revision_entity", "org.hibernate.envers.use_revision_entity_with_native_id",
"org.hibernate.envers.use_enhanced_revision_entity", "org.hibernate.envers.use_revision_entity_with_native_id",
"false"); "true");
useEnhancedRevisionEntity = Boolean.parseBoolean(useEnhancedRevisionEntityStr); useRevisionEntityWithNativeId = Boolean.parseBoolean(useRevisionEntityWithNativeIdStr);
hasGlobalSettingForWithModifiedFlag = hasGlobalSettingForWithModifiedFlag =
properties.getProperty(GLOBAL_WITH_MODIFIED_FLAG_PROPERTY) != null; properties.getProperty(GLOBAL_WITH_MODIFIED_FLAG_PROPERTY) != null;
@ -191,7 +191,7 @@ public class GlobalConfiguration {
return modifiedFlagSuffix; return modifiedFlagSuffix;
} }
public boolean isUseEnhancedRevisionEntity() { public boolean isUseRevisionEntityWithNativeId() {
return useEnhancedRevisionEntity; return useRevisionEntityWithNativeId;
} }
} }

View File

@ -45,6 +45,8 @@ import org.hibernate.envers.RevisionNumber;
import org.hibernate.envers.RevisionTimestamp; import org.hibernate.envers.RevisionTimestamp;
import org.hibernate.envers.configuration.metadata.AuditTableData; import org.hibernate.envers.configuration.metadata.AuditTableData;
import org.hibernate.envers.configuration.metadata.MetadataTools; 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.entities.PropertyData;
import org.hibernate.envers.revisioninfo.DefaultRevisionInfoGenerator; import org.hibernate.envers.revisioninfo.DefaultRevisionInfoGenerator;
import org.hibernate.envers.revisioninfo.DefaultTrackingModifiedEntitiesRevisionInfoGenerator; import org.hibernate.envers.revisioninfo.DefaultTrackingModifiedEntitiesRevisionInfoGenerator;
@ -75,10 +77,10 @@ public class RevisionInfoConfiguration {
public RevisionInfoConfiguration(GlobalConfiguration globalCfg) { public RevisionInfoConfiguration(GlobalConfiguration globalCfg) {
this.globalCfg = globalCfg; this.globalCfg = globalCfg;
if (globalCfg.isUseEnhancedRevisionEntity()) { if (globalCfg.isUseRevisionEntityWithNativeId()) {
revisionInfoEntityName = "org.hibernate.envers.enhanced.DefaultRevisionEntity";
} else {
revisionInfoEntityName = "org.hibernate.envers.DefaultRevisionEntity"; revisionInfoEntityName = "org.hibernate.envers.DefaultRevisionEntity";
} else {
revisionInfoEntityName = "org.hibernate.envers.enhanced.SequenceIdRevisionEntity";
} }
revisionInfoIdData = new PropertyData("id", "id", "field", null); revisionInfoIdData = new PropertyData("id", "id", "field", null);
revisionInfoTimestampData = new PropertyData("timestamp", "timestamp", "field", null); revisionInfoTimestampData = new PropertyData("timestamp", "timestamp", "field", null);
@ -97,7 +99,7 @@ public class RevisionInfoConfiguration {
class_mapping.addAttribute("table", "REVINFO"); class_mapping.addAttribute("table", "REVINFO");
Element idProperty = MetadataTools.addNativelyGeneratedId(class_mapping, revisionInfoIdData.getName(), 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); MetadataTools.addColumn(idProperty, "REV", null, null, null, null, null, null, false);
Element timestampProperty = MetadataTools.addProperty(class_mapping, revisionInfoTimestampData.getName(), Element timestampProperty = MetadataTools.addProperty(class_mapping, revisionInfoTimestampData.getName(),
@ -296,8 +298,8 @@ public class RevisionInfoConfiguration {
Class<? extends RevisionListener> revisionListenerClass = getRevisionListenerClass(revisionEntity.value()); Class<? extends RevisionListener> revisionListenerClass = getRevisionListenerClass(revisionEntity.value());
revisionInfoTimestampType = pc.getProperty(revisionInfoTimestampData.getName()).getType(); revisionInfoTimestampType = pc.getProperty(revisionInfoTimestampData.getName()).getType();
if (globalCfg.isTrackEntitiesChangedInRevisionEnabled() if (globalCfg.isTrackEntitiesChangedInRevisionEnabled()
|| (!globalCfg.isUseEnhancedRevisionEntity() && DefaultTrackingModifiedEntitiesRevisionEntity.class.isAssignableFrom(revisionInfoClass)) || (globalCfg.isUseRevisionEntityWithNativeId() && DefaultTrackingModifiedEntitiesRevisionEntity.class.isAssignableFrom(revisionInfoClass))
|| (globalCfg.isUseEnhancedRevisionEntity() && org.hibernate.envers.enhanced.DefaultTrackingModifiedEntitiesRevisionEntity.class.isAssignableFrom(revisionInfoClass)) || (!globalCfg.isUseRevisionEntityWithNativeId() && SequenceIdTrackingModifiedEntitiesRevisionEntity.class.isAssignableFrom(revisionInfoClass))
|| modifiedEntityNamesFound.isSet()) { || modifiedEntityNamesFound.isSet()) {
// If tracking modified entities parameter is enabled, custom revision info entity is a subtype // If tracking modified entities parameter is enabled, custom revision info entity is a subtype
// of DefaultTrackingModifiedEntitiesRevisionEntity class, or @ModifiedEntityNames annotation is used. // of DefaultTrackingModifiedEntitiesRevisionEntity class, or @ModifiedEntityNames annotation is used.
@ -319,14 +321,14 @@ public class RevisionInfoConfiguration {
if (revisionInfoGenerator == null) { if (revisionInfoGenerator == null) {
if (globalCfg.isTrackEntitiesChangedInRevisionEnabled()) { if (globalCfg.isTrackEntitiesChangedInRevisionEnabled()) {
revisionInfoClass = globalCfg.isUseEnhancedRevisionEntity() ? org.hibernate.envers.enhanced.DefaultTrackingModifiedEntitiesRevisionEntity.class revisionInfoClass = globalCfg.isUseRevisionEntityWithNativeId() ? DefaultTrackingModifiedEntitiesRevisionEntity.class
: DefaultTrackingModifiedEntitiesRevisionEntity.class; : SequenceIdTrackingModifiedEntitiesRevisionEntity.class;
revisionInfoEntityName = revisionInfoClass.getName(); revisionInfoEntityName = revisionInfoClass.getName();
revisionInfoGenerator = new DefaultTrackingModifiedEntitiesRevisionInfoGenerator(revisionInfoEntityName, revisionInfoClass, revisionInfoGenerator = new DefaultTrackingModifiedEntitiesRevisionInfoGenerator(revisionInfoEntityName, revisionInfoClass,
revisionListenerClass, revisionInfoTimestampData, isTimestampAsDate(), modifiedEntityNamesData); revisionListenerClass, revisionInfoTimestampData, isTimestampAsDate(), modifiedEntityNamesData);
} else { } else {
revisionInfoClass = globalCfg.isUseEnhancedRevisionEntity() ? org.hibernate.envers.enhanced.DefaultRevisionEntity.class revisionInfoClass = globalCfg.isUseRevisionEntityWithNativeId() ? DefaultRevisionEntity.class
: DefaultRevisionEntity.class; : SequenceIdRevisionEntity.class;
revisionInfoGenerator = new DefaultRevisionInfoGenerator(revisionInfoEntityName, revisionInfoClass, revisionInfoGenerator = new DefaultRevisionInfoGenerator(revisionInfoEntityName, revisionInfoClass,
revisionListenerClass, revisionInfoTimestampData, isTimestampAsDate()); revisionListenerClass, revisionInfoTimestampData, isTimestampAsDate());
} }

View File

@ -41,19 +41,19 @@ import org.hibernate.mapping.Formula;
public class MetadataTools { public class MetadataTools {
public static Element addNativelyGeneratedId(Element parent, String name, String type, public static Element addNativelyGeneratedId(Element parent, String name, String type,
boolean useEnhancedRevisionEntity) { boolean useRevisionEntityWithNativeId) {
Element id_mapping = parent.addElement("id"); Element id_mapping = parent.addElement("id");
id_mapping.addAttribute("name", name).addAttribute("type", type); id_mapping.addAttribute("name", name).addAttribute("type", type);
Element generator_mapping = id_mapping.addElement("generator"); 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.addAttribute("class", "org.hibernate.id.enhanced.SequenceStyleGenerator");
generator_mapping.addElement("param").addAttribute("name", "sequence_name").setText("REVISION_GENERATOR"); 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", "table_name").setText("REVISION_GENERATOR");
generator_mapping.addElement("param").addAttribute("name", "initial_value").setText("1"); generator_mapping.addElement("param").addAttribute("name", "initial_value").setText("1");
generator_mapping.addElement("param").addAttribute("name", "increment_size").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.addAttribute("class", "sequence");
// generator_mapping.addElement("param").addAttribute("name", "sequence").setText("custom"); // generator_mapping.addElement("param").addAttribute("name", "sequence").setText("custom");

View File

@ -41,7 +41,7 @@ import java.util.Date;
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com) * @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
*/ */
@MappedSuperclass @MappedSuperclass
public class DefaultRevisionEntity implements Serializable { public class SequenceIdRevisionEntity implements Serializable {
private static final long serialVersionUID = 4159156677698841902L; private static final long serialVersionUID = 4159156677698841902L;
@Id @Id
@ -83,9 +83,9 @@ public class DefaultRevisionEntity implements Serializable {
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; 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 (id != that.id) return false;
if (timestamp != that.timestamp) return false; if (timestamp != that.timestamp) return false;
@ -100,6 +100,6 @@ public class DefaultRevisionEntity implements Serializable {
} }
public String toString() { public String toString() {
return "DefaultRevisionEntity(id = " + id + ", revisionDate = " + DateFormat.getDateTimeInstance().format(getRevisionDate()) + ")"; return "SequenceIdRevisionEntity(id = " + id + ", revisionDate = " + DateFormat.getDateTimeInstance().format(getRevisionDate()) + ")";
} }
} }

View File

@ -32,13 +32,13 @@ import java.util.HashSet;
import java.util.Set; 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} * This revision entity is implicitly used when {@code org.hibernate.envers.track_entities_changed_in_revision}
* parameter is set to {@code true}. * parameter is set to {@code true}.
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com) * @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
*/ */
@MappedSuperclass @MappedSuperclass
public class DefaultTrackingModifiedEntitiesRevisionEntity extends DefaultRevisionEntity { public class SequenceIdTrackingModifiedEntitiesRevisionEntity extends SequenceIdRevisionEntity {
@ElementCollection(fetch = FetchType.EAGER) @ElementCollection(fetch = FetchType.EAGER)
@JoinTable(name = "REVCHANGES", joinColumns = @JoinColumn(name = "REV")) @JoinTable(name = "REVCHANGES", joinColumns = @JoinColumn(name = "REV"))
@Column(name = "ENTITYNAME") @Column(name = "ENTITYNAME")
@ -56,10 +56,10 @@ public class DefaultTrackingModifiedEntitiesRevisionEntity extends DefaultRevisi
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;
if (!(o instanceof DefaultTrackingModifiedEntitiesRevisionEntity)) return false; if (!(o instanceof SequenceIdTrackingModifiedEntitiesRevisionEntity )) return false;
if (!super.equals(o)) return false; if (!super.equals(o)) return false;
DefaultTrackingModifiedEntitiesRevisionEntity that = (DefaultTrackingModifiedEntitiesRevisionEntity) o; SequenceIdTrackingModifiedEntitiesRevisionEntity that = (SequenceIdTrackingModifiedEntitiesRevisionEntity) o;
if (modifiedEntityNames != null ? !modifiedEntityNames.equals(that.modifiedEntityNames) if (modifiedEntityNames != null ? !modifiedEntityNames.equals(that.modifiedEntityNames)
: that.modifiedEntityNames != null) return false; : that.modifiedEntityNames != null) return false;
@ -74,6 +74,6 @@ public class DefaultTrackingModifiedEntitiesRevisionEntity extends DefaultRevisi
} }
public String toString() { public String toString() {
return "DefaultTrackingModifiedEntitiesRevisionEntity(" + super.toString() + ", modifiedEntityNames = " + modifiedEntityNames + ")"; return "SequenceIdTrackingModifiedEntitiesRevisionEntity(" + super.toString() + ", modifiedEntityNames = " + modifiedEntityNames + ")";
} }
} }

View File

@ -43,7 +43,7 @@ public abstract class AbstractOneSessionTest extends AbstractEnversTest {
config.setProperty("org.hibernate.envers.audit_strategy", auditStrategy); config.setProperty("org.hibernate.envers.audit_strategy", auditStrategy);
} }
config.setProperty( Environment.USE_NEW_ID_GENERATOR_MAPPINGS, "true" ); 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); addProperties(config);
this.initMappings(); this.initMappings();

View File

@ -49,7 +49,7 @@ public abstract class BaseEnversFunctionalTestCase extends BaseCoreFunctionalTes
@Override @Override
protected Configuration constructConfiguration() { protected Configuration constructConfiguration() {
Configuration configuration = super.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; return configuration;
} }

View File

@ -114,7 +114,7 @@ public abstract class BaseEnversJPAFunctionalTestCase extends AbstractEnversTest
ejb3Configuration ejb3Configuration
.getHibernateConfiguration() .getHibernateConfiguration()
.setProperty( "org.hibernate.envers.use_enhanced_revision_entity", "true" ); .setProperty( "org.hibernate.envers.use_revision_entity_with_native_id", "false" );
ejb3Configuration ejb3Configuration
.getHibernateConfiguration() .getHibernateConfiguration()

View File

@ -3,7 +3,7 @@ package org.hibernate.envers.test.entities.reventity.trackmodifiedentities;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import org.hibernate.envers.enhanced.DefaultTrackingModifiedEntitiesRevisionEntity; import org.hibernate.envers.enhanced.SequenceIdTrackingModifiedEntitiesRevisionEntity;
import org.hibernate.envers.RevisionEntity; import org.hibernate.envers.RevisionEntity;
/** /**
@ -11,7 +11,7 @@ import org.hibernate.envers.RevisionEntity;
*/ */
@Entity @Entity
@RevisionEntity(ExtendedRevisionListener.class) @RevisionEntity(ExtendedRevisionListener.class)
public class ExtendedRevisionEntity extends DefaultTrackingModifiedEntitiesRevisionEntity { public class ExtendedRevisionEntity extends SequenceIdTrackingModifiedEntitiesRevisionEntity {
@Column(name = "USER_COMMENT") @Column(name = "USER_COMMENT")
private String comment; private String comment;

View File

@ -8,6 +8,7 @@ import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase;
import org.hibernate.envers.test.Priority; import org.hibernate.envers.test.Priority;
import org.hibernate.envers.test.entities.IntTestEntity; import org.hibernate.envers.test.entities.IntTestEntity;
import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.hibernate.testing.jta.TestingJtaBootstrap; import org.hibernate.testing.jta.TestingJtaBootstrap;
@ -60,7 +61,7 @@ public class JtaTransaction extends BaseEnversJPAFunctionalTestCase {
@Test @Test
public void testRevisionsCounts() throws Exception { 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 @Test
@ -68,7 +69,7 @@ public class JtaTransaction extends BaseEnversJPAFunctionalTestCase {
IntTestEntity ver1 = new IntTestEntity(10, id1); IntTestEntity ver1 = new IntTestEntity(10, id1);
IntTestEntity ver2 = new IntTestEntity(20, id1); IntTestEntity ver2 = new IntTestEntity(20, id1);
assert getAuditReader().find(IntTestEntity.class, id1, 1).equals(ver1); Assert.assertEquals(ver1, getAuditReader().find(IntTestEntity.class, id1, 1));
assert getAuditReader().find(IntTestEntity.class, id1, 2).equals(ver2); Assert.assertEquals(ver2, getAuditReader().find(IntTestEntity.class, id1, 2));
} }
} }

View File

@ -29,7 +29,7 @@ import javax.persistence.EntityManager;
import org.junit.Test; import org.junit.Test;
import org.hibernate.ejb.Ejb3Configuration; 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.RevisionType;
import org.hibernate.envers.query.AuditEntity; import org.hibernate.envers.query.AuditEntity;
import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase; import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase;
@ -95,7 +95,7 @@ public class DeletedEntities extends BaseEnversJPAFunctionalTestCase {
assert result.size() == 1; assert result.size() == 1;
assert ((Object []) result.get(0))[0].equals(new StrIntTestEntity("b", 11, id2)); 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); assert ((Object []) result.get(0))[2].equals(RevisionType.ADD);
} }
} }

View File

@ -32,7 +32,7 @@ import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.hibernate.ejb.Ejb3Configuration; 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.RevisionType;
import org.hibernate.envers.query.AuditEntity; import org.hibernate.envers.query.AuditEntity;
import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase; 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(1))[0].equals(new StrIntTestEntity("c", 10, id1));
assert ((Object []) result.get(2))[0].equals(new StrIntTestEntity(null, null, id1)); assert ((Object []) result.get(2))[0].equals(new StrIntTestEntity(null, null, id1));
assert ((DefaultRevisionEntity) ((Object []) result.get(0))[1]).getId() == 1; assert ((SequenceIdRevisionEntity) ((Object []) result.get(0))[1]).getId() == 1;
assert ((DefaultRevisionEntity) ((Object []) result.get(1))[1]).getId() == 2; assert ((SequenceIdRevisionEntity) ((Object []) result.get(1))[1]).getId() == 2;
assert ((DefaultRevisionEntity) ((Object []) result.get(2))[1]).getId() == 4; assert ((SequenceIdRevisionEntity) ((Object []) result.get(2))[1]).getId() == 4;
assert ((Object []) result.get(0))[2].equals(RevisionType.ADD); assert ((Object []) result.get(0))[2].equals(RevisionType.ADD);
assert ((Object []) result.get(1))[2].equals(RevisionType.MOD); assert ((Object []) result.get(1))[2].equals(RevisionType.MOD);

View File

@ -59,7 +59,7 @@ public class DifferentDBSchemaTest extends BaseEnversJPAFunctionalTestCase {
@Test @Test
public void testRevinfoSchemaName() { 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()); assert SCHEMA_NAME.equals(revisionTable.getSchema());
} }

View File

@ -24,7 +24,7 @@
package org.hibernate.envers.test.integration.reventity; package org.hibernate.envers.test.integration.reventity;
import javax.persistence.Entity; import javax.persistence.Entity;
import org.hibernate.envers.enhanced.DefaultRevisionEntity; import org.hibernate.envers.enhanced.SequenceIdRevisionEntity;
import org.hibernate.envers.RevisionEntity; import org.hibernate.envers.RevisionEntity;
/** /**
@ -32,5 +32,5 @@ import org.hibernate.envers.RevisionEntity;
*/ */
@Entity @Entity
@RevisionEntity @RevisionEntity
public class InheritedRevEntity extends DefaultRevisionEntity { public class InheritedRevEntity extends SequenceIdRevisionEntity {
} }

View File

@ -28,7 +28,6 @@ import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties;
import java.util.Set; import java.util.Set;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.Query; import javax.persistence.Query;
@ -42,7 +41,7 @@ import org.hibernate.dialect.MySQL5Dialect;
import org.hibernate.dialect.PostgreSQL82Dialect; import org.hibernate.dialect.PostgreSQL82Dialect;
import org.hibernate.dialect.SQLServerDialect; import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.ejb.Ejb3Configuration; 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.strategy.ValidityAuditStrategy;
import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase; import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase;
import org.hibernate.envers.test.Priority; import org.hibernate.envers.test.Priority;
@ -66,7 +65,7 @@ public class ValidityAuditStrategyRevEndTsTest extends BaseEnversJPAFunctionalTe
private Integer c1_2_id; private Integer c1_2_id;
private Integer c2_1_id; private Integer c2_1_id;
private Integer c2_2_id; private Integer c2_2_id;
private Map<Number, DefaultRevisionEntity> revisions; private Map<Number, SequenceIdRevisionEntity> revisions;
public void configure(Ejb3Configuration cfg) { public void configure(Ejb3Configuration cfg) {
cfg.addAnnotatedClass(ParentEntity.class); cfg.addAnnotatedClass(ParentEntity.class);
@ -204,7 +203,8 @@ public class ValidityAuditStrategyRevEndTsTest extends BaseEnversJPAFunctionalTe
Set<Number> revisionNumbers = new HashSet<Number>(); Set<Number> revisionNumbers = new HashSet<Number>();
revisionNumbers.addAll(Arrays.asList(1, 2, 3, 4, 5)); revisionNumbers.addAll(Arrays.asList(1, 2, 3, 4, 5));
revisions = getAuditReader().findRevisions(DefaultRevisionEntity.class, revisions = getAuditReader().findRevisions(
SequenceIdRevisionEntity.class,
revisionNumbers); revisionNumbers);
assert revisions.size() == 5; assert revisions.size() == 5;
@ -423,7 +423,7 @@ public class ValidityAuditStrategyRevEndTsTest extends BaseEnversJPAFunctionalTe
private void verifyRevEndTimeStamps(String debugInfo, List<Map<String, Object>> revisionEntities) { private void verifyRevEndTimeStamps(String debugInfo, List<Map<String, Object>> revisionEntities) {
for (Map<String, Object> revisionEntity : revisionEntities) { for (Map<String, Object> revisionEntity : revisionEntities) {
Date revendTimestamp = (Date) revisionEntity.get(revendTimestampColumName); Date revendTimestamp = (Date) revisionEntity.get(revendTimestampColumName);
DefaultRevisionEntity revEnd = (DefaultRevisionEntity) revisionEntity.get("REVEND"); SequenceIdRevisionEntity revEnd = (SequenceIdRevisionEntity) revisionEntity.get("REVEND");
if (revendTimestamp == null) { if (revendTimestamp == null) {
Assert.assertNull(revEnd); Assert.assertNull(revEnd);

View File

@ -99,7 +99,7 @@ public abstract class AbstractEntityManagerTest extends AbstractEnversTest {
if ( createSchema() ) { if ( createSchema() ) {
configurationProperties.setProperty( Environment.HBM2DDL_AUTO, "create-drop" ); configurationProperties.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
configurationProperties.setProperty( Environment.USE_NEW_ID_GENERATOR_MAPPINGS, "true" ); 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)) { if (auditStrategy != null && !"".equals(auditStrategy)) {
configurationProperties.setProperty("org.hibernate.envers.audit_strategy", auditStrategy); configurationProperties.setProperty("org.hibernate.envers.audit_strategy", auditStrategy);

View File

@ -1,6 +1,5 @@
package org.hibernate.envers.test.performance; package org.hibernate.envers.test.performance;
import java.net.URISyntaxException;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -9,12 +8,11 @@ import java.util.Set;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.hibernate.MappingException;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.engine.spi.EntityEntry; import org.hibernate.engine.spi.EntityEntry;
import org.hibernate.engine.spi.PersistenceContext; import org.hibernate.engine.spi.PersistenceContext;
import org.hibernate.engine.spi.SessionImplementor; 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.BaseEnversFunctionalTestCase;
import org.hibernate.envers.test.entities.StrTestEntity; import org.hibernate.envers.test.entities.StrTestEntity;
import org.hibernate.envers.test.entities.onetomany.SetRefEdEntity; 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 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.", 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()));
} }
} }
} }

View File

@ -32,7 +32,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; 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.envers.configuration.GlobalConfiguration;
import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property; import org.hibernate.mapping.Property;
@ -83,7 +83,7 @@ public class TestTools {
public static List<Integer> extractRevisionNumbers(List queryResults) { public static List<Integer> extractRevisionNumbers(List queryResults) {
List<Integer> result = new ArrayList<Integer>(); List<Integer> result = new ArrayList<Integer>();
for (Object queryResult : queryResults) { for (Object queryResult : queryResults) {
result.add(((DefaultRevisionEntity) ((Object[]) queryResult)[1]) result.add(((SequenceIdRevisionEntity) ((Object[]) queryResult)[1])
.getId()); .getId());
} }
return result; return result;