HHH-7187 - Renaming and documenting enhanced revision entity
This commit is contained in:
parent
c41fee2a07
commit
95ec3457af
|
@ -251,6 +251,25 @@
|
|||
evaluates to true
|
||||
</entry>
|
||||
</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>
|
||||
<entry>
|
||||
<property>org.hibernate.envers.track_entities_changed_in_revision</property>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<? extends RevisionListener> 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());
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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()) + ")";
|
||||
}
|
||||
}
|
|
@ -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 + ")";
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
}
|
||||
|
|
|
@ -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<Number, DefaultRevisionEntity> revisions;
|
||||
private Map<Number, SequenceIdRevisionEntity> revisions;
|
||||
|
||||
public void configure(Ejb3Configuration cfg) {
|
||||
cfg.addAnnotatedClass(ParentEntity.class);
|
||||
|
@ -204,7 +203,8 @@ public class ValidityAuditStrategyRevEndTsTest extends BaseEnversJPAFunctionalTe
|
|||
|
||||
Set<Number> revisionNumbers = new HashSet<Number>();
|
||||
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<Map<String, Object>> revisionEntities) {
|
||||
for (Map<String, Object> 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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<Integer> extractRevisionNumbers(List queryResults) {
|
||||
List<Integer> result = new ArrayList<Integer>();
|
||||
for (Object queryResult : queryResults) {
|
||||
result.add(((DefaultRevisionEntity) ((Object[]) queryResult)[1])
|
||||
result.add(((SequenceIdRevisionEntity) ((Object[]) queryResult)[1])
|
||||
.getId());
|
||||
}
|
||||
return result;
|
||||
|
|
Loading…
Reference in New Issue